public ActionResult AddResourceKey(LocaleResourceKeyViewModel newResourceKeyViewModel) { try { var resourceKeyToSave = new LocaleResourceKey { Name = newResourceKeyViewModel.Name, Notes = newResourceKeyViewModel.Notes, DateAdded = newResourceKeyViewModel.DateAdded }; LocalizationService.Add(resourceKeyToSave); Context.SaveChanges(); ShowSuccess("Resource key created successfully"); var currentLanguage = SettingsService.GetSettings().DefaultLanguage.Id; return(RedirectToAction("ManageLanguageResourceValues", new { languageId = currentLanguage })); } catch (Exception ex) { Context.RollBack(); ShowError(ex.Message); LoggingService.Error(ex); return(RedirectToAction("AddResourceKey")); } }
public ActionResult DeleteResourceConfirmation(Guid resourceKeyId) { using (UnitOfWorkManager.NewUnitOfWork()) { try { using (UnitOfWorkManager.NewUnitOfWork()) { var resourceKey = LocalizationService.GetResourceKey(resourceKeyId); var viewModel = new LocaleResourceKeyViewModel { Id = resourceKey.Id, Name = resourceKey.Name, Notes = resourceKey.Notes, DateAdded = resourceKey.DateAdded }; return(View(viewModel)); } } catch (Exception ex) { ShowError(ex.Message); LoggingService.Error(ex); return(View("Index")); } } }
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(); ShowSuccess("Resource key created successfully"); var currentLanguage = SettingsService.GetSetting("DefaultLanguage"); return(RedirectToAction("ManageLanguageResourceValues", new { languageId = currentLanguage })); } catch (Exception ex) { unitOfWork.Rollback(); ShowError(ex.Message); LoggingService.Error(ex); return(RedirectToAction("AddResourceKey")); } } }
public ActionResult EditAll(Guid resourceKeyId) { try { var resourceKey = LocalizationService.GetResourceKey(resourceKeyId); var localeResourceKeyViewModel = new LocaleResourceKeyViewModel { Id = resourceKey.Id, Name = resourceKey.Name, Notes = resourceKey.Notes, DateAdded = resourceKey.DateAdded }; var viewModel = new AllResourceValuesViewModel { ResourceKey = localeResourceKeyViewModel, ResourceValues = new Dictionary <LanguageDisplayViewModel, LocaleResourceViewModel>() }; foreach (var localeStringResource in LocalizationService.GetAllValuesForKey(resourceKeyId)) { var stringResourceViewModel = new LocaleResourceViewModel { Id = localeStringResource.Id, ResourceKeyId = localeStringResource.LocaleResourceKey.Id, LocaleResourceKey = localeStringResource.LocaleResourceKey.Name, ResourceValue = localeStringResource.ResourceValue }; var languageViewModel = new LanguageDisplayViewModel { Id = localeStringResource.Language.Id, IsDefault = localeStringResource.Language.Id == LocalizationService.CurrentLanguage.Id, Name = localeStringResource.Language.Name, LanguageCulture = localeStringResource.Language.LanguageCulture }; if (!viewModel.ResourceValues.ContainsKey(languageViewModel)) { viewModel.ResourceValues.Add(languageViewModel, stringResourceViewModel); } else { viewModel.ResourceValues[languageViewModel] = stringResourceViewModel; } } //Context.SaveChanges(); return(View("ListAllValues", viewModel)); } catch (Exception ex) { //Context.RollBack(); ShowError(ex.Message); LoggingService.Error(ex); return(RedirectToAction("Index")); } }
public ActionResult AddResourceKey() { var resourceKey = LocalizationService.CreateEmptyLocaleResourceKey(); var viewModel = new LocaleResourceKeyViewModel { Id = resourceKey.Id, Name = resourceKey.Name, Notes = resourceKey.Notes, DateAdded = resourceKey.DateAdded }; return(View(viewModel)); }
public ActionResult AddResourceKey() { var viewModel = new LocaleResourceKeyViewModel(); return(View(viewModel)); }