Skip to content

Instantly share code, notes, and snippets.

@cwe1ss
Created August 9, 2014 13:18
Show Gist options
  • Save cwe1ss/cbf39bac616877166dc1 to your computer and use it in GitHub Desktop.
Save cwe1ss/cbf39bac616877166dc1 to your computer and use it in GitHub Desktop.
public class HomeController : Controller
{
private readonly IAppCookies _cookies;
public HomeController(IAppCookies cookies)
{
_cookies = cookies;
}
public ActionResult Index()
{
DateTime currentTime = DateTime.Now;
IndexViewModel viewModel = new IndexViewModel
{
CurrentTime = currentTime,
LastVisit = (_cookies.LastVisit ?? currentTime),
UserEmail = _cookies.UserEmail
};
_cookies.LastVisit = currentTime;
return View(viewModel);
}
public class IndexViewModel
{
public string UserEmail { get; set; }
public DateTime LastVisit { get; set; }
public DateTime CurrentTime { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment