public IActionResult Parameters(int level, string type, int id)
        {
            ParametersVM model = new ParametersVM()
            {
                Level = level,
                Type  = type,
                ID    = id
            };

            return(View(model));
        }
Beispiel #2
0
        public Calculation SaveCalculation(ParametersVM parameters, IEnumerable <BaseSingleNPVCalculation> NPVs)
        {
            Calculation npvc = new Calculation
            {
                CalculationDate        = DateTime.Now,
                DiscountRateIncrement  = parameters.DiscountRateIncrement,
                InitialValue           = parameters.InitialValue,
                LowerBoundDiscountRate = parameters.LowerBoundDiscountRate,
                UpperBoundDiscountRate = parameters.UpperBoundDiscountRate
            };

            dbContext.NPVCalculations.Add(npvc);
            dbContext.SaveChanges();

            SaveCashflows(parameters.Cashflows, npvc.ID);
            SaveSingleNPVCalculations(NPVs, npvc.ID);

            return(npvc);
        }
Beispiel #3
0
        public IEnumerable <SingleNPVCalculation> ProcessCalculation(ParametersVM parameters)
        {
            List <SingleNPVCalculation> npvCalculations = new List <SingleNPVCalculation>();

            for (
                decimal discountRate = parameters.LowerBoundDiscountRate;
                discountRate <= parameters.UpperBoundDiscountRate;
                discountRate += parameters.DiscountRateIncrement
                )
            {
                decimal NPV = calculationService.CalculateNPV(parameters.Cashflows, discountRate, parameters.InitialValue);
                npvCalculations.Add(new SingleNPVCalculation {
                    DiscountRate = discountRate, NPV = NPV
                });
            }

            calculationService.SaveCalculation(parameters, npvCalculations);

            return(npvCalculations);
        }
Beispiel #4
0
        public IHttpActionResult Calculate(ParametersVM parameters)
        {
            IEnumerable <SingleNPVCalculation> npvCalculations = service.ProcessCalculation(parameters);
            IEnumerable <Cashflow>             cashFlows       = parameters.Cashflows.Select(y => new Cashflow {
                Value = y
            });

            var x = new Calculation
            {
                CalculationDate        = DateTime.Now,
                Cashflows              = cashFlows.ToArray(),
                DiscountRateIncrement  = parameters.DiscountRateIncrement,
                InitialValue           = parameters.InitialValue,
                LowerBoundDiscountRate = parameters.LowerBoundDiscountRate,
                UpperBoundDiscountRate = parameters.UpperBoundDiscountRate,
                ResultSet              = npvCalculations.ToArray()
            };

            return(Ok(x));
        }