Пример #1
0
        public async Task <int> ManageNPVCalculation(CalculateNPVApiRequest request)
        {
            var calculateNPVRequest = new CalculateNPVRequest
            {
                InitialInvestment      = request.InitialInvestment.Value,
                LowerBoundDiscountRate = request.LowerBoundDiscountRate.Value / 100,
                UpperBoundDiscountRate = request.UpperBoundDiscountRate.Value / 100,
                DiscountRateIncrement  = request.DiscountRateIncrement.Value / 100
            };
            var requestId = await DB.InsertAsync(calculateNPVRequest);

            var cashFlows = await ManageCashFlows(request, requestId);

            await ManageNPVResults(calculateNPVRequest, cashFlows, requestId);

            return(requestId);
        }
Пример #2
0
        private async Task <List <CashFlow> > ManageCashFlows(CalculateNPVApiRequest request, int requestId)
        {
            var cashFlows     = new List <CashFlow>();
            var cashFlowOrder = 1;

            foreach (var cashFlow in request.CashFlows)
            {
                cashFlows.Add(new CashFlow
                {
                    CashFlowValue = cashFlow,
                    CashFlowOrder = cashFlowOrder,
                    RequestId     = requestId
                });
                cashFlowOrder = cashFlowOrder + 1;
            }
            await DB.InsertListAsync <CashFlow>(cashFlows);

            return(cashFlows);
        }