Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Language()
        {
            var model = new AdminLanguageSettingViewModel
            {
                LanguageDefault = LocalizationService.DefaultLanguage.Id,
                AllLanguage     = LocalizationService.GetBaseSelectListLanguages(LocalizationService.GetAll())
            };

            return(View("Language", model));
        }
Ejemplo n.º 3
0
        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));
        }