예제 #1
0
        public ActionResult AddResourceKey(LocaleResourceKeyViewModel newResourceKeyViewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    var resourceKeyToSave = new LocaleResourceKey
                    {
                        Name  = newResourceKeyViewModel.Name,
                        Notes = newResourceKeyViewModel.Notes
                    };

                    LocalizationService.Add(resourceKeyToSave);
                    unitOfWork.Commit();
                    LocalizationService.Clear();
                    ShowSuccess("Resource key created successfully");
                    //var currentLanguage = SettingsService.GetSetting("DefaultLanguage");
                    return(RedirectToAction("ManageResourceKeys"));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    ShowError(ex.Message);
                    LoggingService.Error(ex);
                    return(RedirectToAction("AddResourceKey"));
                }
            }
        }
예제 #2
0
 public void UpdateResourceValue(AjaxEditLanguageValueViewModel viewModel)
 {
     if (Request.IsAjaxRequest())
     {
         using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
         {
             try
             {
                 LocalizationService.UpdateResourceString(viewModel.LanguageId, viewModel.ResourceKey,
                                                          viewModel.NewValue);
                 unitOfWork.Commit();
                 LocalizationService.Clear();
             }
             catch (Exception ex)
             {
                 unitOfWork.Rollback();
                 LoggingService.Error(ex);
             }
         }
     }
 }
예제 #3
0
        public ActionResult DeleteLanguage1(Guid Id)
        {
            var language = LocalizationService.Get(Id);

            if (language == null)
            {
                return(RedirectToAction("Index"));
            }

            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    LocalizationService.Delete(language);

                    unitOfWork.Commit();
                    LocalizationService.Clear();
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Xóa gói ngôn ngữ thành công"),
                        MessageType = GenericMessages.success
                    };
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex.Message);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Có lỗi xảy ra!"),
                        MessageType = GenericMessages.warning
                    };
                }
            }

            return(View(language));
        }