public async Task <IActionResult> Create([Bind("ID,Material,Shape,Color,Size_MM,Quantity,Price_Point")] Bead bead) { if (ModelState.IsValid) { _context.Add(bead); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bead)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Bead.Add(Bead); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Bead = await _context.Bead.FindAsync(id); if (Bead != null) { _context.Bead.Remove(Bead); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Bead).State = EntityState.Modified; try{ await _context.SaveChangesAsync(); }catch (DbUpdateConcurrencyException) { if (!BeadExists(Bead.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }