public IActionResult Index() { var db = new ListingsDb(_connectionString); var vm = new ListingsViewModel(); vm.Listings = db.GetListings(); List <int> ids = HttpContext.Session.Get <List <int> >("Ids"); if (ids != null) { vm.Ids = ids; } return(View(vm)); }
public IActionResult IndexCookie() { var db = new ListingsDb(_connectionString); var vm = new ListingsViewModel(); vm.Listings = db.GetListings(); List <int> ids = new List <int>(); if (Request.Cookies["ids"] != null) { string idString = Request.Cookies["ids"]; foreach (string num in idString.Split(",")) { ids.Add(int.Parse(num)); } } vm.Ids = ids; return(View(vm)); }