public TargetingType DeserializeToTargetingType(
            TargetingTypeInfo targetingTypeInfo,
            TaxonomyRepository taxonomyRepository,
            IEnumerable <TargetingTypePortfolioInfo> whateverPortfolioCompositionInfos,
            PortfolioRepository portfolioRepository
            )
        {
            var taxonomy = taxonomyRepository.GetTaxonomy(targetingTypeInfo.TaxonomyId);

            var owned = whateverPortfolioCompositionInfos
                        .Where(x => x.TargetingTypeId == targetingTypeInfo.Id);

            var broadGlobalActivePortfolios = owned
                                              .Select(x => portfolioRepository.FindBroadGlobalActivePortfolio(x.PortfolioId))
                                              .Where(x => x != null);

            var bottomUpPortfolios = this.GetBottomUpPortfolios(owned, portfolioRepository);

            var result = new TargetingType(
                targetingTypeInfo.Id,
                targetingTypeInfo.Name,
                targetingTypeInfo.TargetingTypeGroupId,
                targetingTypeInfo.BenchmarkIdOpt,
                taxonomy,
                broadGlobalActivePortfolios,
                bottomUpPortfolios
                );

            return(result);
        }
示例#2
0
        public TargetingType DeserializeTargetingType(
            TargetingTypeInfo targetingTypeInfo,
            IEnumerable <TargetingTypePortfolioCompositionInfo> whateverCompositionInfos,
            TaxonomyRepository taxonomyRepository
            )
        {
            var taxonomy = taxonomyRepository.GetTaxonomy(targetingTypeInfo.TaxonomyId);

            var portfolios = whateverCompositionInfos
                             .Where(x => x.TargetingTypeId == targetingTypeInfo.Id)
                             .Select(x => new Portfolio(x.PortfolioId));

            var result = new TargetingType(
                targetingTypeInfo.Id,
                targetingTypeInfo.Name,
                targetingTypeInfo.BenchmarkIdOpt,
                taxonomy,
                portfolios
                );

            return(result);
        }