public async Task <CalcularJurosCompostosResult> CalcularJurosCompostosAsync(CalcularJurosCompostosCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var result = await _jurosService.CorrigirValorAsync(command.ValorInicial, command.Meses);

            return(new CalcularJurosCompostosResult {
                ValorCorrigido = result.ValorFinal
            });
        }
Esempio n. 2
0
 public async Task <IActionResult> Get([FromQuery] decimal valorInicial, [FromQuery] int meses)
 {
     try
     {
         var command = new CalcularJurosCompostosCommand {
             ValorInicial = valorInicial, Meses = meses
         };
         return(Ok(await _jurosAppService.CalcularJurosCompostosAsync(command)));
     }
     catch (ParametrosDeCalculoInvalidosException ex)
     {
         _logger.LogError(ex, ex.Message);
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, ex.Message);
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }