public void GetAggregateInvestSum() { var sum1 = _balanceService.GetAggregateInvestSum(new [] { 1, 2 }, 1); var sum2 = _balanceService.GetAggregateInvestSum(new [] { 1, 2, 3 }, 1); var sum3 = _balanceService.GetAggregateInvestSum(new [] { 3 }, 2); var sum4 = _balanceService.GetInvestSum(3, 3); Assert.AreEqual(2350000, sum1); Assert.AreEqual(2350000, sum2); Assert.AreEqual(50000, sum3); Assert.AreEqual(0, sum4); }
public async Task <OperationResult <CostWithInvestSum> > AggregatePortfolioCostWithInvestSum( [CurrentUserIdGlobalState] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService, [Service] IBalanceService balanceService, IEnumerable <int> portfolioIds) { var ids = portfolioIds.ToList(); var cost = await aggregatePortfolioService.AggregateCost(ids, userId); if (!cost.IsSuccess) { return(new OperationResult <CostWithInvestSum>() { IsSuccess = cost.IsSuccess, Message = cost.Message }); } var investSum = balanceService.GetAggregateInvestSum(ids, userId); return(new OperationResult <CostWithInvestSum>() { IsSuccess = true, Message = "Суммарная стоимость и суммарнаые инвестиции", Result = new CostWithInvestSum() { Cost = cost.Result, InvestSum = investSum } }); }
public static AllPortfoliosReport GetAllPortfoliosReport(int userId, IMarketService marketService, IBalanceService balanceService, IAggregatePortfolioService aggregatePortfolioService) { var allCostResult = aggregatePortfolioService.AggregateCost(new[] { 1, 2 }, userId).Result; var allCost = FinanceHelpers.GetPriceDouble(allCostResult.Result); var paperProfitResult = aggregatePortfolioService.AggregatePaperProfit(new[] { 1, 2 }, userId).Result.Result; var allPaperProfit = FinanceHelpers.GetPriceDouble(paperProfitResult.Value); var allPaperProfitPercent = paperProfitResult.Percent; var paymentProfitResult = aggregatePortfolioService.AggregatePaymentProfit(new[] { 1, 2 }, userId).Result.Result; var allPaymentProfit = FinanceHelpers.GetPriceDouble(paymentProfitResult.Value); var allPaymentProfitPercent = paymentProfitResult.Percent; var allInvestSum = FinanceHelpers.GetPriceDouble(balanceService.GetAggregateInvestSum(new [] { 1, 2 }, userId)); var balanceResult = balanceService.AggregateBalance(new[] { 1, 2 }, userId).Result; var allBalance = FinanceHelpers.GetPriceDouble(balanceResult.Result); return(new AllPortfoliosReport() { AllCost = allCost, AllPaperProfit = allPaperProfit, AllPaperProfitPercent = allPaperProfitPercent, AllPaymentProfit = allPaymentProfit, AllPaymentProfitPercent = allPaymentProfitPercent, AllInvestSum = allInvestSum, AllUserBalance = allBalance }); }
public int GetAggregateInvestSum([CurrentUserIdGlobalState] int userId, [Service] IBalanceService balanceService, IEnumerable <int> portfolioIds) { return(balanceService.GetAggregateInvestSum(portfolioIds, userId)); }