public async Task <IActionResult> Edit(int id, [Bind("Id,Typ")] Bagnet bagnet) { if (id != bagnet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bagnet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BagnetExists(bagnet.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bagnet)); }
public async Task <IActionResult> Create([Bind("Id,Typ")] Bagnet bagnet) { if (ModelState.IsValid) { if (!BagnetNameExists(bagnet.Typ)) { _context.Add(bagnet); await _context.SaveChangesAsync(); ViewBag.DuplicateMessage = ""; return(RedirectToAction(nameof(Index))); } else { ViewBag.DuplicateMessage = "This already exists"; } } return(View(bagnet)); }