public async Task <IActionResult> Edit(int id, [Bind("ID,Nome")] Departamento departamento) { if (id != departamento.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departamento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartamentoExists(departamento.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departamento)); }
public async Task UpdateAsync(Vendedor obj) { if (!await _context.Vendedor.AnyAsync(x => x.Id == obj.Id)) { throw new NotFoundException("ID não encontrado"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public void Update(Vendedor obj) { if (!_context.Vendedor.Any(x => x.Id == obj.Id)) { throw new NotFoundException("Id not found"); } try { _context.Update(obj); _context.SaveChanges(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task AtualizarAsync(Vendedor obj) { bool hasAny = await _context.Vendedor.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Vendedor não existe"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task UpdateAsync(Seller obj) { bool hasAny = await _context.Seller.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Id não encontrado"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task AtualizarAsync(Vendedor obj) { var existeVendedor = await _context.Vendedor.AnyAsync(v => v.Id == obj.Id); if (!existeVendedor) { throw new NotFoundException("Id não encontrado!"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task AtualizarAsync(Vendedor obj) { bool temAlgum = await _contexto.Vendedor.AnyAsync(x => x.Id == obj.Id); if (!temAlgum) { throw new NotFoundException("Id não encontrado!"); } try { _contexto.Update(obj); await _contexto.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }