private List <PortfolioData> GetPortfoliosData(int userId, bool isForceUpdate = false) { if (_portfolios != null && !isForceUpdate) { return(_portfolios); } var portfolios = new List <PortfolioData>(); var userPortfolios = _financeDataService.EfContext.Portfolios .Where(p => p.UserId == userId); foreach (var userPortfolio in userPortfolios) { var portfolioData = new PortfolioData { Id = userPortfolio.Id, Name = userPortfolio.Name, UserId = userPortfolio.UserId, Assets = _assetsFactory.Create(userPortfolio.Id) }; portfolios.Add(portfolioData); } _portfolios = portfolios; return(portfolios); }
private PortfolioData GetPortfolioData(int portfolioId) { var userPortfolio = _financeData.EfContext.Portfolios .Find(portfolioId); if (userPortfolio == null) { return(null); } var portfolioData = new PortfolioData { Id = userPortfolio.Id, Name = userPortfolio.Name, UserId = userPortfolio.UserId, Assets = _assetsFactory.Create(portfolioId) }; return(portfolioData); }