Example #1
0
        public async Task <ActionResult <decimal> > CalcularJuros([FromQuery(Name = "valorInicial")] decimal valorInicial, [FromQuery(Name = "meses")] int meses)
        {
            var taxaJuros = await _taxaJurosService.PegarTaxaJuros();

            var valorJuros = _calculaJurosService.CalcularJuros(valorInicial, meses, taxaJuros);

            return(valorJuros);
        }
        public async Task <IActionResult> CalcularJuros([FromQuery] CalculaJurosRequest objRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            decimal resultado = await iCalcularJurosService.CalcularJuros(objMapper.Map <CalculaJuros>(objRequest));

            return(Ok(resultado));
        }
Example #3
0
        public async Task <IActionResult> CalculaJuros(decimal valorinicial, int meses)
        {
            try
            {
                var resultado = await _calculaJurosService.CalcularJuros(valorinicial, meses);

                return(Ok(resultado));
            }
            catch (Exception e)
            {
                return(BadRequest($"Erro: {e.Message}"));
            }
        }
Example #4
0
        public async Task <IActionResult> GetCalcularJuros([FromQuery] decimal valorInicial, [FromQuery] int meses)
        {
            var resultado = await _calculaJurosService.CalcularJuros(valorInicial, meses);

            return(Ok(resultado));
        }
        public void calculo_juros_should_be_success()
        {
            decimal valor = _calculaJurosService.CalcularJuros(100, 5, 0.01);

            Assert.Equal(Convert.ToDecimal(105.10), valor);
        }