Ejemplo n.º 1
0
        public InterestRateResponse GetInterestRateList(InterestRateRequest Request)
        {
            InterestRateResponse InterestRateResponse = new InterestRateResponse();

            ErrorList[]    lstErrorLst     = new ErrorList[1];
            InterestList[] lstInterestList = new InterestList[Request.TermListGroup.Length];
            double         maxValue        = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["Max"]);
            double         minValue        = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["Min"]);

            try
            {
                InterestRateResponse.CorrelationID = Request.CorrelationID;
                InterestRateResponse.RequestID     = Request.RequestID;
                InterestRateResponse.SuccessFlag   = true;
                for (int i = 0; i < Request.TermListGroup.Length; i++)
                {
                    InterestList InterestList = new InterestList();
                    InterestList.Term            = Request.TermListGroup[i].Term;
                    InterestList.MaxInterestRate = maxValue;
                    InterestList.MinInterestRate = minValue;
                    lstInterestList[i]           = InterestList;
                }
                InterestRateResponse.InterestListGroup = lstInterestList;
                InterestRateResponse.ErrorListGroup    = lstErrorLst;
            }
            catch (Exception ex)
            {
                InterestRateResponse.SuccessFlag = false;
                ErrorList ErrorList = new ErrorList();
                ErrorList.ErrorMessage = ex.Message;
                lstErrorLst[1]         = ErrorList;
                InterestRateResponse.ErrorListGroup = lstErrorLst;
            }
            return(InterestRateResponse);
        }
Ejemplo n.º 2
0
        public async Task <string> Get([FromQuery] InterestRateRequest interestRateRequest)
        {
            var currentInterestRate = await _rateService.GetCurrentInterestRate();

            var resultado = _rateCalculator.Calculate(interestRateRequest, currentInterestRate);

            return($"{resultado:0.##}");
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> GetInterestRate([FromQuery] InterestRateRequest interestRateRequest)
 {
     return(Ok(await _sender.Send(interestRateRequest)));
 }
 public float Calculate(InterestRateRequest interestRateRequest, float currentInterestRate) =>
 interestRateRequest.InitialValue * (float)Math.Pow(1 + currentInterestRate, interestRateRequest.Months);