Пример #1
0
        public static Entities.DTO.Elegible GetCommenFoElegible(DateTime DateOfBirth)
        {
            Entities.DTO.Elegible result = null;

            try
            {
                int    age = 0;
                string msgForNotElegible = string.Empty;

                age = DateTime.Today.Year - DateOfBirth.Year;
                if (age < 18)
                {
                    msgForNotElegible = "Lo Sentimos aun no cuenta con la edad para solicitar este producto.";
                }

                if (age > 25)
                {
                    msgForNotElegible = "Favor pasar por una de nuestras sucursales para evaluar su caso.";
                }

                result = new Entities.DTO.Elegible()
                {
                    Age        = age,
                    IsElegible = (age > 18 && age < 25) ? true : false,
                    Comment    = msgForNotElegible
                };
            }
            catch (Exception e)
            {
                _ = e.Message;
            }

            return(result);
        }
Пример #2
0
        public IHttpActionResult getCalculationFee(Calculate value)
        {
            try
            {
                // Checking ege, if the client is elegible, comment will be empty,
                // otherwise this method will return a message according to age.
                Entities.DTO.Elegible Eligibility = Business.LoanBook.GetCommenFoElegible(value.DateOfBirth);

                // If client is elegible, calculate fee and save consultation.
                decimal calclatedFee = Business.LoanBook.CalculationFee(value.Amount, value.RateValue, value.MonthValue);

                // Save consultation log
                var consultation = new Entities.Models.LoanConsultation()
                {
                    Age       = Eligibility.Age,
                    Amount    = value.Amount,
                    Months    = value.MonthValue,
                    AmountFee = calclatedFee,
                    IPClient  = value.IPClient
                };

                int result = Business.LoanConsultation.Add(consultation);
                if (result != 0)
                {
                    return(Eligibility.IsElegible == false?
                           BadRequest(Eligibility.Comment) :
                               (IHttpActionResult)Ok(calclatedFee));
                }
                else
                {
                    return(BadRequest("No se pudo obtener la cuota."));
                }
            }
            catch (Exception ex)
            {
                _ = ex.Message;
                return(BadRequest("Ha ocurrido un error."));
            }
        }