public async Task <IActionResult> Update(int id) { //Get the single video game out of the db VideoGame game = await VideoGameDb.GetGameById(id, _context); return(View(game)); }
public async Task <IActionResult> Update(int id) { VideoGame game = await VideoGameDb.GetGameById(id, _context); return(View(game)); }
public async Task <IActionResult> Add(int id) { VideoGame g = await VideoGameDb.GetGameById(id, _context); CartHelper.Add(_httpAccessor, g); return(RedirectToAction("Index", "Library")); //// Set up cookie //CookieOptions options = new CookieOptions() //{ // Secure = true, // MaxAge = TimeSpan.FromDays(365) // A whole year //}; //_httpAccessor.HttpContext.Response.Cookies.Append("CartCookie", data, options); }
// Add the game to a cookie public async Task <IActionResult> Add(int id) { VideoGame g = await VideoGameDb.GetGameById(id, _context); CartHelper.Add(_httpAccessor, g); /* * string data = JsonConvert.SerializeObject(g); * CookieOptions options = new CookieOptions() * { * Secure = true, * MaxAge = TimeSpan.FromDays(14) * }; * * _httpAccessor.HttpContext.Response.Cookies.Append("CartCookie", data, options); */ return(RedirectToAction("Index", "Library")); }
public async Task <IActionResult> Add(int id) { //Get the game with the corresponding id VideoGame g = await VideoGameDb.GetGameById(id, _context); //Convert game to a string CartHelper.Add(_httpAccessor, g); //Set up cookie //CookieOptions options = new CookieOptions() //{ // Secure = true, // MaxAge = TimeSpan.FromDays(365) //The cookie data will last up to a year //}; //_httpAccessor.HttpContext.Response.Cookies.Append("CartCookie", data, options); return(RedirectToAction("Index", "Library")); }
public async Task <IActionResult> Add(int id) { VideoGame g = await VideoGameDb.GetGameById(id, _context); CartHelper.Add(_httpAccessor, g); return(RedirectToAction("Index", "Library")); // get game with the associated id, add the game to a cookie, // redirect to catalog, // convert object to string using Json.NET //string data = JsonConvert.SerializeObject(g); //// set up cookie //CookieOptions options = new CookieOptions() //{ // Secure = true, // MaxAge = TimeSpan.FromDays(14) // two weeks //}; //_httpAccessor.HttpContext.Response.Cookies.Append("CartCookie", data, options); }