Beispiel #1
0
        /// <summary>
        /// Fills the create map object model.
        /// </summary>
        /// <param name="model">The model.</param>
        public static void FillCreateMapObjectModel(IRoadsService client, CreateMapObjectViewModel model)
        {
            var lang = GetLanguages(client);

                var languages = new SelectList(lang.Select(s =>
                    new SelectListItem
                    {
                        Value = s.LanguageId.ToString(CultureInfo.InvariantCulture),
                        Text = s.Name,
                        Selected = s.IsDefault
                    }), "Value", "Text", lang.First(e => e.IsDefault).LanguageId);

                if (model.Translations.Any())
                {
                    foreach (var t in model.Translations)
                    {
                        t.LanguageKey = "null";
                        t.Languages = languages;
                    }
                }
                else
                {
                    foreach (var l in languages)
                    {
                        model.Translations.Add(new TranslationViewModel
                        {
                            Languages = languages,
                            LanguageKey = "null",
                            LanguageId = int.Parse(l.Value)
                        });
                    }
                }

                string selectedLanguage = CultureHelper.GetCulture(Thread.CurrentThread.CurrentUICulture.Name);

                var regions = client.GetRegionsListForLanguage(selectedLanguage);

                model.Regions = new SelectList(regions.Select(s => new SelectListItem
                {
                    Value = s.Id.ToString(CultureInfo.InvariantCulture),
                    Text = s.Name,
                    Selected = false
                }), "Value", "Text", 1);
        }