public async Task <IActionResult> Edit(int id, [Bind("ClientesID,Nombre,Apellido,Direccion,Telefono")] Clientes clientes) { if (id != clientes.ClientesID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clientes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientesExists(clientes.ClientesID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clientes)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department) { if (id != department.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,UserName,Email,PhoneNumber,CPF,ReleaseDate,Convenio,Coment")] clientes clientes) { if (id != clientes.ClienteID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clientes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!clientesExists(clientes.ClienteID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clientes)); }
public bool Alterar(ref Clientes cliente) { try { using (ClientesContext ctx = new ClientesContext()) { var result = ctx.Update(cliente); ctx.SaveChanges(); return(true); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task UpdateAsync(Customers obj) { bool hasAny = await _context.Customers.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Id not found"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }