Пример #1
0
        public async Task <BancoResponse> UpdateAsync(int bancoId, Banco banco)
        {
            if (banco == null)
            {
                return(new BancoResponse(_localizer["BancoEsNulo"]));
            }

            var existingBanco = await _bancoRepository.FindByIdAsync(bancoId);

            if (existingBanco == null)
            {
                return(new BancoResponse(_localizer["BancoNotFound"]));
            }

            existingBanco.Nombre = banco.Nombre;
            existingBanco.Código = banco.Código;

            try
            {
                _bancoRepository.Update(existingBanco);
                await _unitOfWork.CompleteAsync();

                return(new BancoResponse(existingBanco));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
//				return new BancoResponse($"An error occurred when updating the banco: {ex.Message}");
                return(new BancoResponse(_localizer["BancoErrorActualizando"] + ex.Message));
            }
        }