public async Task <ServiceResponse <GetClienteDto> > UpdateCharacter(UpdateClienteDto updatedCliente) { ServiceResponse <GetClienteDto> serviceResponse = new ServiceResponse <GetClienteDto>(); try { Cliente cliente = await _context.Clientes.FirstOrDefaultAsync(c => c.Id == updatedCliente.Id); cliente.Rut = updatedCliente.Rut; cliente.Nombre = updatedCliente.Nombre; cliente.Apellidos = updatedCliente.Apellidos; cliente.FechaNacimiento = updatedCliente.FechaNacimiento; cliente.Direccion = updatedCliente.Direccion; cliente.Telefono = updatedCliente.Telefono; _context.Clientes.Update(cliente); await _context.SaveChangesAsync(); serviceResponse.Data = _mapper.Map <GetClienteDto>(cliente); } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = ex.Message; } return(serviceResponse); }
public async Task <RedirectToRouteResult> UpdatingCliente(UpdateClienteDto Cliente) { if (!await RepositoryCliente.GetInstance(_context, _mapper).UpdateClienteDto(Cliente)) { return(RedirectToAction("UpdateCliente", new { @Cliente = Cliente, @error = true })); } return(RedirectToAction("GetListCliente")); }
public async Task <IActionResult> UpdateCliente(UpdateClienteDto updateCliente) { ServiceResponse <GetClienteDto> response = await _clienteService.UpdateCliente(updateCliente); if (response.Data == null) { return(NotFound(response)); } return(Ok(response)); }
public async Task <ActionResult> UpdateCliente(string cedula, UpdateClienteDto Cliente, bool error = false) { if (cedula == null) { if (Cliente == null) { return(RedirectToAction("GetListCliente", new { @error = true })); } else { ViewBag.error = error; return(View(Cliente)); } } else { UpdateClienteDto ClienteDto = await RepositoryCliente.GetInstance(_context, _mapper).GetClientePerId(cedula); return(View(ClienteDto)); } }