public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } // var siteToUpdate = await _context.FavoriteWebSites.FindAsync(id); _context.Attach(FavoriteWebSites).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FavoriteWebSitesExists(FavoriteWebSites.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Cart).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CartExists(Cart.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } if (UserBeef.Quantity > 0) { var newProduct = new Cart() { DateCreated = DateTime.Now, OwnerID = User.Identity.Name, Price = (UserBeef.Price * UserBeef.Quantity), ItemsInToCart = UserBeef.Quantity, ProductID = UserBeef.ProductID }; _context.Carts.Add(newProduct); } await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Carts.Add(Cart); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } FavoriteWebSites.OwnerID = User.Identity.Name; _context.FavoriteWebSites.Add(FavoriteWebSites); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } PlayerData = await _context.PlayerData.FindAsync(id); if (PlayerData != null) { _context.PlayerData.Remove(PlayerData); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } BeefObject = await _context.Beef.FindAsync(id); if (BeefObject != null) { _context.Beef.Remove(BeefObject); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } FavoriteWebSites = await _context.FavoriteWebSites.FindAsync(id); if (FavoriteWebSites != null) { _context.FavoriteWebSites.Remove(FavoriteWebSites); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int playGame) { Console.WriteLine("Adding {0} Some thing{1}", 12, 15); if (!ModelState.IsValid) { return(Page()); } //var newProduct = new Cart() //{ // DateCreated = DateTime.Now, // OwnerID = User.Identity.Name, // Price = playGame, // ItemsInToCart = 1 //}; //_context.Carts.Add(newProduct); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }