public async Task <ServiceResponse <GetCuentaDto> > UpdateCuenta(UpdateCuentaDto updatedCuenta) { ServiceResponse <GetCuentaDto> serviceResponse = new ServiceResponse <GetCuentaDto>(); try { Cuenta cuenta = await _context.Cuentas.Include(c => c.Cliente) .FirstOrDefaultAsync(c => c.Id == updatedCuenta.Id); cuenta.TipoCuenta = (BancoChiloe.Models.TipoCuenta)updatedCuenta.TipoCuenta; cuenta.FechaApertura = updatedCuenta.FechaApertura; cuenta.NombreUsuario = updatedCuenta.NombreUsuario; cuenta.Saldo = updatedCuenta.Saldo; cuenta.SaldoInicial = updatedCuenta.SaldoInicial; _context.Cuentas.Update(cuenta); await _context.SaveChangesAsync(); serviceResponse.Data = _mapper.Map <GetCuentaDto>(cuenta); } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = ex.Message; } return(serviceResponse); }
public async Task <IActionResult> UpdateCliente(UpdateCuentaDto updateCuenta) { ServiceResponse <GetCuentaDto> response = await _cuentaService.UpdateCuenta(updateCuenta); if (response.Data == null) { return(NotFound(response)); } return(Ok(response)); }