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 async Task <OperationResult <List <Payment> > > AggregatePortfolioPayments( [CurrentUserIdGlobalState] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService, int[] portfolioIds) { return(await aggregatePortfolioService.AggregatePayments(portfolioIds, userId)); }
public async Task <OperationResult <int> > AggregatePortfolioCost( [CurrentUserIdGlobalState] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService, IEnumerable <int> portfolioIds) { return(await aggregatePortfolioService.AggregateCost(portfolioIds, userId)); }
public void Setup() { var mockHttp = new MockHttpMessageHandler(); var client = mockHttp.ToHttpClient(); var context = TestHelpers.GetMockFinanceDbContext(); _financeDataService = new FinanceDataService(context); var balanceService = new BalanceService(_financeDataService); TestHelpers.SeedApp(context); var stockMarketApi = new StockMarketAPI(client); var stockMarketData = new StockMarketData(stockMarketApi); var assetFactory = new AssetsFactory(_financeDataService, stockMarketData); var portfolioService = new PortfolioService(_financeDataService, balanceService, assetFactory); _aggregatePortfolioService = new AggregatePortfolioService(portfolioService, balanceService); TestHelpers.MockStockData(mockHttp); TestHelpers.MockFondData(mockHttp); TestHelpers.MockBondData(mockHttp); TestHelpers.SeedOperations2(context); }
public AllPortfoliosReport GetAllPortfoliosReport( [CurrentUserIdGlobalState] int userId, [Service] IMarketService marketService, [Service] IBalanceService balanceService, [Service] IAggregatePortfolioService aggregatePortfolioService) { return(QueryGetters.GetAllPortfoliosReport(userId, marketService, balanceService, aggregatePortfolioService)); }
public AllPortfoliosReport OnUpdatePortfoliosReport( [Service] IMarketService marketService, [Service] IBalanceService balanceService, [EventMessage] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService) { return(QueryGetters.GetAllPortfoliosReport(userId, marketService, balanceService, aggregatePortfolioService)); }
public async Task <List <BondReport> > AggregateBonds( [CurrentUserIdGlobalState] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService, IEnumerable <int> portfolioIds) { var bonds = aggregatePortfolioService.AggregateBonds(portfolioIds, userId); return(await GetBondReports(bonds)); }
public async Task <List <StockReport> > AggregateStocks( [CurrentUserIdGlobalState] int userId, [Service] IAggregatePortfolioService aggregatePortfolioService, IEnumerable <int> portfolioIds) { var stocks = aggregatePortfolioService.AggregateStocks(portfolioIds, userId); return(await GetStockReports(stocks)); }
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 }); }