// To protect from overposting attacks, 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(Supplement).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplementExists(Supplement.SupplementID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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.CartItems.Add(Cart); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Supplement = await _context.Supplements.FindAsync(id); if (Supplement != null) { _context.Supplements.Remove(Supplement); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TrainingRoutine = await _context.TrainingRoutines.FindAsync(id); if (TrainingRoutine != null) { _context.TrainingRoutines.Remove(TrainingRoutine); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }