public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Departament departament) { if (id != departament.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departament); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartamentExists(departament.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departament)); }
public async Task UpdateAsync(Seller seller) { bool hasAny = await _context.Seller.AnyAsync(x => x.Id == seller.Id); if (!hasAny) { throw new NotFoundException("Id not found"); } try { _context.Update(seller); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }