Beispiel #1
0
        public decimal GenerateLoan(ViewModelLoan viewModelLoan)
        {
            viewModelLoan.Age = DateTime.Now.Year - viewModelLoan.BirthDate.Year;

            if (viewModelLoan.BirthDate.Date > DateTime.Now.AddYears(-viewModelLoan.Age.Value))
            {
                viewModelLoan.Age--;
            }
            if (viewModelLoan.Age < 18)
            {
                throw new Exception("Lo sentimos, aun no cuenta con la edad para solicitar este producto.");
            }
            if (viewModelLoan.Age > 25)
            {
                throw new Exception("Favor pasar por una de nuestras sucursales para evaluar su caso.");
            }
            if (!viewModelLoan.Months.HasValue)
            {
                throw new Exception("Especifique la cantidad de meses del prestamo");
            }
            if (string.IsNullOrEmpty(viewModelLoan.UserLog))
            {
                throw new Exception("Especifique a nombre de quien esta el prestamo");
            }

            return(new LoanManagement().GenerateLoan(viewModelLoan));
        }
 public decimal GenerateLoan(ViewModelLoan viewModelLoan)
 {
     loanCalculatorEntities.INSERT_QUERY_LOG(viewModelLoan.Age, viewModelLoan.Amount, viewModelLoan.Months, viewModelLoan.UserLog);
     return(loanCalculatorEntities.QUERY_LOG.FirstOrDefault(x => x.MONTHS == viewModelLoan.Months && x.QUERY_IP == viewModelLoan.UserLog && x.AGE == viewModelLoan.Age).MONTHLY_PAYMENT.Value);
 }