public ConsumerPortfolioScheme GetScheme(string id)
        {
            // get the portfolio
            var portfolio = this.Mongo.GetConsumerPortfolio(id);

            // create the portfolio scheme
            var portfolioScheme = new ConsumerPortfolioScheme(portfolio);

            // add the members
            var members = this.Mongo.GetConsumerPortfolioMembers(portfolio.Id);

            portfolioScheme.Members.AddRange(members);

            return(portfolioScheme);
        }
예제 #2
0
        public ConsumerMember GetScheme(string memberId, string portfoliId = null)
        {
            // get the current member
            var member = this.Collection.FindAll().Where(item => item.Id == memberId).FirstOrDefault();

            if (portfoliId == null)
            {
                // create all the portfolio schemes
                var portfolios = this.Mongo.GetConsumerMemberPortfolios(memberId).OrderBy(item => item, _consumerPortfolioComparer).ToList();

                foreach (var portfolio in portfolios)
                {
                    // create the portfolio scheme
                    var portfolioScheme = new ConsumerPortfolioScheme(portfolio);

                    // add the members
                    var members = this.Mongo.GetConsumerPortfolioMembers(portfolio.Id, member.Id);
                    portfolioScheme.Members.AddRange(members);

                    // add to the member's list of portfolio schemes
                    member.Portfolios.Add(portfolioScheme);
                }
            }
            else
            {
                // create this portfolio schemes
                var portfolio = this.Mongo.GetConsumerPortfolio(portfoliId);

                // create the portfolio scheme
                var portfolioScheme = new ConsumerPortfolioScheme(portfolio);

                // add the members
                var members = this.Mongo.GetConsumerPortfolioMembers(portfolio.Id, member.Id);
                portfolioScheme.Members.AddRange(members);

                // add to the member's list of portfolio schemes
                member.Portfolios.Add(portfolioScheme);
            }

            return(member);
        }