// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Calendar).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CalendarExists(Calendar.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <RedirectResult> OnPost() { Cart = await _context.Cart.ToListAsync(); int x = 0; foreach (var item in Cart) { x = x + 1; } for (int i = 0; i < x; i++) { _context.Cart.Remove(Cart[i]); } await _context.SaveChangesAsync(); var mealInfo = Request.Form["ordered"] + ", " + Request.Form["qtyOrder"] + ", " + Request.Form["pickupLocation"] + ", " + Request.Form["pickupTime"] + ", " + Request.Form["pickupDay"] + "\n"; System.IO.File.AppendAllText("./Pages/Shared/OrderedMeals.txt", mealInfo); TempData["alertMessage"] = "Order was placed sucessfuly"; return(Redirect("../Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Cart.Add(Cart); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Cart = await _context.Cart.FindAsync(id); if (Cart != null) { _context.Cart.Remove(Cart); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }