public static async Task <List <FondReport> > GetFondReports(int userId, IPortfolioService portfolioService, int portfolioId) { var fonds = portfolioService.GetFonds(portfolioId, userId); var fondReports = new List <FondReport>(); foreach (var fondInfo in fonds) { var name = await fondInfo.GetName(); var price = await fondInfo.GetPrice(); var percentChange = await fondInfo.GetPriceChange(); var allPrice = await fondInfo.GetAllPrice(); var paperProfit = await fondInfo.GetPaperProfit(); var paperProfitPercent = await fondInfo.GetPaperProfitPercent(); var updateTime = await fondInfo.GetUpdateTime(); var fondReport = new FondReport() { Name = name, Ticket = fondInfo.Ticket, Price = price, PriceChange = FinanceHelpers.GetPriceDouble(percentChange), AllPrice = FinanceHelpers.GetPriceDouble(allPrice), BoughtPrice = FinanceHelpers.GetPriceDouble(fondInfo.BoughtPrice), Amount = fondInfo.Amount, PaperProfit = FinanceHelpers.GetPriceDouble(paperProfit), PaperProfitPercent = paperProfitPercent, UpdateTime = updateTime, }; fondReports.Add(fondReport); } return(fondReports); }
public IEnumerable <FondInfo> AggregateFonds(IEnumerable <int> portfolioIds, int userId) { return(portfolioIds.SelectMany(portfolioId => _portfolioService.GetFonds(portfolioId, userId))); }