示例#1
0
        /// <summary>Loads the ag sales areas.</summary>
        /// <param name="campaignProgramme">The campaign programme.</param>
        /// <param name="salesAreas">The sales areas.</param>
        /// <returns></returns>
        protected AgSalesAreas LoadAgSalesAreas(CampaignProgramme campaignProgramme, IEnumerable <SalesArea> salesAreas)
        {
            var mapped = campaignProgramme.SalesAreas.Any()
                ? salesAreas.Where(s => campaignProgramme.SalesAreas.Contains(s.Name))
                         .Select(s => new AgSalesArea {
                SalesAreaNumber = s.CustomId
            }).ToList()
                : salesAreas.Select(s => new AgSalesArea {
                SalesAreaNumber = s.CustomId
            }).ToList();

            var agSalesAreas = new AgSalesAreas();

            agSalesAreas.AddRange(mapped);

            return(agSalesAreas);
        }
示例#2
0
        /// <summary>Loads the ag programme programme category.</summary>
        /// <param name="campaignProgramme">The campaign programme.</param>
        /// <param name="programmeDictionaries">The programme dictionaries.</param>
        /// <param name="programmeCategories">The programme categories.</param>
        /// <returns></returns>
        protected AgCampaignProgrammeProgrammeCategories LoadAgProgrammeProgrammeCategory(
            CampaignProgramme campaignProgramme,
            IEnumerable <ProgrammeDictionary> programmeDictionaries,
            IEnumerable <ProgrammeCategoryHierarchy> programmeCategories)
        {
            var mapped = new AgCampaignProgrammeProgrammeCategories();

            if (campaignProgramme.IsCategoryOrProgramme.EqualInvariantCultureIgnoreCase(
                    CategoryOrProgramme.P.ToString()))
            {
                var programmes = programmeDictionaries
                                 .Where(c => campaignProgramme.CategoryOrProgramme.Any(p =>
                                                                                       p.Equals(c.ExternalReference.ToString(), StringComparison.OrdinalIgnoreCase)))
                                 .Select(c => new AgCampaignProgrammeProgrammeCategory
                {
                    ProgrammeNumber = c.Id,
                    CategoryNumber  = 0
                })
                                 .ToList();

                mapped.AddRange(programmes);
            }
            else
            {
                var categories = programmeCategories
                                 .Where(c =>
                                        campaignProgramme.CategoryOrProgramme.Any(p => p.EqualInvariantCultureIgnoreCase(c.Name)))
                                 .Select(c => new AgCampaignProgrammeProgrammeCategory
                {
                    CategoryNumber  = c.Id,
                    ProgrammeNumber = 0
                })
                                 .ToList();

                mapped.AddRange(categories);
            }

            return(mapped);
        }