コード例 #1
0
        public PartialViewResult GetLanguages()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var viewModel = new ListLanguagesViewModel {
                    Languages = new List <LanguageDisplayViewModel>()
                };

                try
                {
                    foreach (var language in LocalizationService.GetAll())
                    {
                        var languageViewModel = new LanguageDisplayViewModel
                        {
                            Id              = language.Id,
                            IsDefault       = language.Id == LocalizationService.CurrentLanguage.Id,
                            Name            = language.Name,
                            LanguageCulture = language.LanguageCulture,
                        };

                        viewModel.Languages.Add(languageViewModel);
                    }
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                    LoggingService.Error(ex);
                }

                return(PartialView(viewModel));
            }
        }
コード例 #2
0
ファイル: SettingController.cs プロジェクト: kaisermtv/WebMvc
        public ActionResult Language()
        {
            var model = new AdminLanguageSettingViewModel
            {
                LanguageDefault = LocalizationService.DefaultLanguage.Id,
                AllLanguage     = LocalizationService.GetBaseSelectListLanguages(LocalizationService.GetAll())
            };

            return(View("Language", model));
        }
コード例 #3
0
ファイル: SettingController.cs プロジェクト: kaisermtv/WebMvc
        public ActionResult Language(AdminLanguageSettingViewModel setting)
        {
            if (ModelState.IsValid)
            {
                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    setting.AllLanguage = LocalizationService.GetBaseSelectListLanguages(LocalizationService.GetAll());

                    try
                    {
                        SettingsService.SetSetting("LanguageDefault", setting.LanguageDefault.ToString());


                        unitOfWork.Commit();
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        LoggingService.Error(ex);
                    }
                }
            }



            return(View("Language", setting));
        }