public async Task <IActionResult> Edit(int id, [Bind("DepartamentoID,Nome")] Departamento departamento) { if (id != departamento.DepartamentoID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departamento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartamentoExists(departamento.DepartamentoID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departamento)); }
public async Task UpdateAsync(Vendedor obj) { bool verifica = await DB.Vendedores.AnyAsync(x => x.VendedorID == obj.VendedorID); if (!verifica) { throw new NotFoundException("ID Não Encontrado!"); } try { DB.Update(obj); await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { throw new DbConcurrencyException(ex.Message); } }