コード例 #1
0
        public static AnalysisGroupFilterSearchModel MapToAnalysisGroupFilterSearchModel(AnalysisGroupFilter filter,
                                                                                         ICampaignRepository campaignRepository,
                                                                                         IClashRepository clashRepository,
                                                                                         IProductRepository productRepository)
        {
            if (filter is null)
            {
                throw new InvalidOperationException("AnalysisGroup filter can not be null");
            }

            return(new AnalysisGroupFilterSearchModel
            {
                Advertisers = productRepository.GetAdvertisers(filter.AdvertiserExternalIds)
                              .ToDictionary(x => x.AdvertiserIdentifier, x => x.AdvertiserName),
                Agencies = productRepository.GetAgencies(filter.AgencyExternalIds)
                           .ToDictionary(x => x.AgencyIdentifier, x => x.AgencyName),
                AgencyGroups = productRepository.GetAgencyGroups(filter.AgencyGroupCodes)
                               .ToDictionary(x => x.Code, x => x.ShortName),
                BusinessTypes = filter.BusinessTypes.Any()
                    ? new HashSet <string>(campaignRepository.GetBusinessTypes())
                    : filter.BusinessTypes,
                Campaigns = campaignRepository.FindNameByRefs(filter.CampaignExternalIds)
                            .ToDictionary(x => x.ExternalId, x => x.Name),
                ClashCodes = clashRepository.GetDescriptionByExternalRefs(filter.ClashExternalRefs)
                             .ToDictionary(x => x.Externalref, x => x.Description),
                Products = productRepository.GetByExternalIds(filter.ProductExternalIds)
                           .ToDictionary(x => x.Externalidentifier, x => x.Name),
                ReportingCategories = filter.ReportingCategories.Any()
                    ? new HashSet <string>(productRepository.GetReportingCategories())
                    : filter.ReportingCategories,
                SalesExecs = productRepository.GetSalesExecutives(filter.SalesExecExternalIds)
                             .ToDictionary(x => x.Identifier, x => x.Name)
            });
        }