Ejemplo n.º 1
0
        public async Task <ActionResult> Quota([FromBody] QueryDto query)
        {
            var rates = await RepositoryAgeRate.GetInstance().Get();

            var months = await RepositoryMonth.GetInstance().Get();

            var rate = rates.FirstOrDefault(x => x.Age == Calculations.CalculateAge(query.DateOfBirth));

            if (rate == null || months == null)
            {
                return(NotFound());
            }

            var month = months.FirstOrDefault(x => x.Value == query.LoanMonths);

            var AccountValue = Calculations.QuotaCalculation(query.LoanAmount, rate.Rate, month.Value);

            var resul = await RepositoryLog.GetInstance().Create(new Domain.Entitys.Log
            {
                ConsultationDate = query.ConsultationDate,
                Edad             = Calculations.CalculateAge(query.DateOfBirth),
                Amount           = query.LoanAmount,
                AccountValue     = AccountValue,
                QueryIp          = GetIp(),
                MonthId          = query.LoanMonths
            });

            if (resul)
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
 public async Task <ActionResult <List <AgeRageDto> > > Get() => await RepositoryAgeRate.GetInstance().Get();