Ejemplo n.º 1
0
        public EmprestimoFormDto Save(EmprestimoFormDto formDto)
        {
            ValidarFormDto(formDto);
            if (!formDto.ValidationSucceeded)
            {
                return(formDto);
            }

            var emprestimo = CriarEmprestimo(formDto);

            if (!emprestimo.IsValid)
            {
                formDto.AddErro(string.Join(',', emprestimo.Erros));
                return(formDto);
            }

            _clienteServices.AlterarOLimiteDeEmprestimoDoCliente(emprestimo.Cliente, formDto.ValorDoEmprestimo);

            _emprestimoRepository.Add(emprestimo);
            _emprestimoRepository.Commit();
            return(formDto);
        }