示例#1
0
        /// <summary>
        /// Populate
        /// </summary>
        /// <param name="languageID"></param>
        public void Populate(Guid languageID)
        {
            //Countries
            var countries = CountryService.GetCountries(languageID);

            Countries = new List <KeyValue>();

            foreach (var country in countries)
            {
                Countries.Add(new KeyValue {
                    Key = country.ID.ToString(), Value = country.Name
                });
            }

            //this.Countries.Insert(0, new KeyValue { Key = "", Value = "Country" });

            //regions
            var regions = RegionService.GetRegions(languageID).OrderBy(r => r.Region.Type).ThenBy(r => r.Name);

            this.Regions = new List <GroupedSelectListItem>();

            foreach (var region in regions)
            {
                this.Regions.Add(new GroupedSelectListItem
                {
                    GroupKey  = region.Region.Type == RegionType.Economical ? "2" : "1",
                    GroupName = region.Region.Type == RegionType.Economical ? "Economical" : "Geographical",
                    Text      = region.Name,
                    Value     = region.ID.ToString()
                });
            }

            //this.Regions.Insert(0, new GroupedSelectListItem { GroupKey = "", GroupName = "", Text = "Region", Value = "" });

            //Documents
            Guid documentTypeVariableID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID));
            var  choiceLanguages        = VariableService.GetChoiceOptions(languageID, documentTypeVariableID);

            this.DocumentTypes = new List <KeyValue>();

            foreach (var choiceLanguage in choiceLanguages)
            {
                this.DocumentTypes.Add(new KeyValue {
                    Key = choiceLanguage.ID.ToString(), Value = choiceLanguage.Name
                });
            }
        }
        /// <summary>
        /// Populate Data
        /// </summary>
        public void Populate(Guid languageID)
        {
            Guid documentTypeVariableID            = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DocumentTypeVariableID));
            var  cacheProvider                     = CacheFactory.Get();
            List <Choice_Language> choiceLanguages = new List <Choice_Language>();

            //Check if cache exists or not
            if (!cacheProvider.Exists(CacheKeys.CACHE_DOCUMENT_TYPE))
            {
                choiceLanguages = VariableService.GetChoiceOptions(languageID, documentTypeVariableID);
                cacheProvider.Add <List <Choice_Language> >(choiceLanguages, CacheKeys.CACHE_DOCUMENT_TYPE, SiteConstants.CacheDuration);
            }
            else
            {
                choiceLanguages = cacheProvider.Get <List <Choice_Language> >(CacheKeys.CACHE_DOCUMENT_TYPE);
            }

            this.Data = new List <KeyValue>();
            var national = choiceLanguages.Where(cl => cl.Name.ToLower() == "national").FirstOrDefault();

            choiceLanguages = choiceLanguages.Where(cl => cl.Name.ToLower() != "national").OrderBy(cl => cl.Name).ToList();

            this.National = new KeyValue();

            //Add National
            if (national != null)
            {
                this.National = new KeyValue
                {
                    Key       = national.ID.ToString(),
                    Value     = national.Name,
                    ClassName = "first-level",
                    Level     = "1"
                };
            }



            foreach (var choiceLanguage in choiceLanguages)
            {
                this.Data.Add(new KeyValue {
                    Key = choiceLanguage.ID.ToString(), Value = choiceLanguage.Name, ClassName = "second-level-last", Level = "2"
                });
            }
        }