public ActionResult Edit([Bind(Include = "Id,Nome,CPF,DataNascimento,Genero,Telefones")] Cliente cliente) { if (ModelState.IsValid) { if (cliente.Telefones != null) { foreach (var telefone in cliente.Telefones) { telefone.IdCliente = cliente.Id; if (telefone.DDD != null || telefone.Numero != null) { if (telefone.Id > 0) { db.Entry(telefone).State = EntityState.Modified; } else { db.Entry(telefone).State = EntityState.Added; } } } } db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
//[Authorize(Roles = "admin,vendedor")] public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEndereco(int id, Endereco endereco) { if (id != endereco.Id) { return(BadRequest()); } _context.Entry(endereco).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnderecoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCliente([FromRoute] int id, [FromBody] Cliente cliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cliente.Id) { return(BadRequest()); } _context.Entry(cliente).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCliente(long id, Cliente cliente) { var header = Request.Headers["X-Debug"]; if (id != cliente.Id) { return(BadRequest()); } _context.Entry(cliente).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(id)) { return(NotFound()); } else { throw; } } if (header.ToString() == "true") { AddHttpHeaders(Response); printLog(); } return(NoContent()); }
//[Authorize(Roles = "admin,vendedor")] public async Task <IActionResult> PutCustomers(int id, Customers customers) { if (id != customers.id) { return(BadRequest()); } _context.Entry(customers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task UpdateAsync(TEntity entity) { _context.Attach(entity); _context.Update <TEntity>(entity); _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); }
//[Authorize(Roles = "admin")] public async Task <IActionResult> PutNaturalPerson(int id, NaturalPerson naturalPerson) { if (id != naturalPerson.id) { return(BadRequest()); } _context.Entry(naturalPerson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NaturalPersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public TEntity Atualizar(TEntity entidade) { var entry = Db.Entry(entidade); DbSet.Attach(entidade); entry.State = EntityState.Modified; return(entidade); }
public int Editar(Conta conta) { using (var context = new ClienteContext()) { context.Contas.Attach(conta); context.Entry(conta).State = EntityState.Modified; return(context.SaveChanges()); } }
public void Update(TEntity entity) { var entityDB = DbSet.Find(entity.Id); entity.Usuario = _variables.UserName; entity.DataAlteracao = DateTime.Now; _context.Entry(entityDB).CurrentValues.SetValues(entity); DbSet.Update(entityDB); }
public ActionResult Edit([Bind(Include = "Id,Nome,DataCadastro")] Cliente cliente) { if (ModelState.IsValid) { db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
public ActionResult Edit([Bind(Include = "Id,Nome,Endereco,Telefone,Email,DataNascimento,Ativo")] Cliente cliente) { if (ModelState.IsValid) { db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
public async Task <IActionResult> PutClienteItem(int id, ClienteItem item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public ActionResult Edit(Cliente cliente) { if (ModelState.IsValid) { cliente.DataAlteracao = DateTime.Now; db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
public async Task <IActionResult> PutConductorItem(string identificacion, ConductorItem item) { if (identificacion != item.Identificacion) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> PutVehiculoItem(string placa, VehiculoItem item) { if (placa != item.Placa) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <Models.Cliente> Atualizar(Models.Cliente cliente) { using (var context = new ClienteContext()) { context.Entry(await context.Clientes.FirstOrDefaultAsync(f => f.Id == cliente.Id)).CurrentValues.SetValues(cliente); if ((await context.SaveChangesAsync()) > 0) { return(cliente); } return(null); } }
public IHttpActionResult DeleteTelefone(int idCliente, int idTelefone) { var cliente = db.Clientes.Find(idCliente); if (cliente == null) { return(NotFound()); } var telefone = cliente.Telefones.FirstOrDefault(t => t.Id == idTelefone); if (telefone == null) { return(NotFound()); } db.Entry(telefone).State = EntityState.Deleted; db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCliente(int id, Cliente cliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cliente.Id) { return(BadRequest("O id informado na URL é diferente do id informado no corpo da requisição")); } if (db.Clientes.Count(c => c.Id == id) == 0) { return(NotFound()); } db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Update(long id, Cliente clientes) { if (id != clientes.Id) { return(BadRequest()); } _context.Entry(clientes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExiste(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutClienteModel(ClienteModel ClienteModel) { try { var cliente = _context.Find <ClienteModel>(ClienteModel.Id); if (cliente == null) { return(NotFound()); } _context.Entry(cliente).State = EntityState.Detached; cliente = ClienteModel; _context.Update(cliente); await _context.SaveChangesAsync(); return(NoContent()); } catch (Exception ex) { var exception = ex; return(BadRequest()); } }
} //Search public virtual void Update(T entity) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); } //Update
public virtual void Atualizar(TEntity entity) { _dbContext.Entry(entity).State = EntityState.Modified; _dbContext.SaveChanges(); }
public virtual void Atualizar(TEntity entity) { _dbContext.Entry(entity).State = EntityState.Modified; // entrei no contexto... para o estado de modificação _dbContext.SaveChanges(); }
public Cliente Alterar(Cliente cliente) { db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(cliente); }
public void Atualizar(Models.Cliente cliente) { _context.Entry(cliente).State = System.Data.Entity.EntityState.Modified; }
public void Atualizar(TEntity entity) { _dbContext.Entry(entity).State = EntityState.Modified; }
public void Atualizar(Endereco endereco) { _context.Entry(endereco).State = System.Data.Entity.EntityState.Modified; }