public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.ID) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//void IRep_Base<Cliente>.UpDateAsync(Cliente Entity) public async Task UpDateAsync(Cliente cliente) { CTX.Entry(cliente).State = EntityState.Modified; try { await CTX.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(cliente.Id)) { throw new ArgumentException( $"Nada encontrado para o cliente {cliente.Nome}.", nameof(cliente.Nome)); } else { throw; } } }
public void UpDate(TEntity obj) { db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); }