public virtual ActionResult Update(long id, RoleLocaleViewModel roleView) { var role = roleService.Find(id); if (role == null) { throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity")); } if (ModelState.IsValid) { var localeService = ServiceLocator.Current.GetInstance <IRoleLocaleService>(); RoleLocale roleLocale = localeService.GetLocale(id, roleView.SelectedCulture) ?? new RoleLocale { Role = role, Culture = roleView.SelectedCulture }; roleLocale.Name = roleView.Name; localeService.Save(roleLocale); Success(Translate("Messages.RoleUpdated")); return(RedirectToAction(MVC.Admin.Role.Index())); } Error(Translate("Messages.ValidationError")); return(View("Edit", roleView)); }
public virtual ActionResult ChangeLanguage(long roleId, String culture) { var role = roleService.Find(roleId); if (role == null) { throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.RoleNotFound")); } RoleLocaleViewModel model = new RoleLocaleViewModel().MapFrom(role); model.SelectedCulture = culture; var localeService = ServiceLocator.Current.GetInstance <IRoleLocaleService>(); RoleLocale locale = localeService.GetLocale(roleId, culture); if (locale != null) { model.Name = locale.Name; } return(PartialView("EditForm", model)); }
public virtual ActionResult Update(long id, RoleLocaleViewModel roleView) { var role = roleService.Find(id); if (role == null) { throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity")); } if (ModelState.IsValid) { var localeService = ServiceLocator.Current.GetInstance<IRoleLocaleService>(); RoleLocale roleLocale = localeService.GetLocale(id, roleView.SelectedCulture) ?? new RoleLocale { Role = role, Culture = roleView.SelectedCulture }; roleLocale.Name = roleView.Name; localeService.Save(roleLocale); Success(Translate("Messages.RoleUpdated")); return RedirectToAction(MVC.Admin.Role.Index()); } Error(Translate("Messages.ValidationError")); return View("Edit", roleView); }
public virtual ActionResult ChangeLanguage(long roleId, String culture) { var role = roleService.Find(roleId); if (role == null) { throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.RoleNotFound")); } RoleLocaleViewModel model = new RoleLocaleViewModel().MapFrom(role); model.SelectedCulture = culture; var localeService = ServiceLocator.Current.GetInstance<IRoleLocaleService>(); RoleLocale locale = localeService.GetLocale(roleId, culture); if (locale != null) { model.Name = locale.Name; } return PartialView("EditForm", model); }