public virtual ActionResult Save(long profileTypeId, ProfileElementViewModel model) { if (ModelState.IsValid) { var profileType = profileTypesService.Find(profileTypeId); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty)); } var profileElement = profileElementService.Find(model.Id); if (profileElementService.Save(model.MapTo(profileElement))) { //save locale var localeService = ServiceLocator.Current.GetInstance <IProfileElementLocaleService>(); ProfileElementLocale locale = localeService.GetLocale(profileElement.Id, model.SelectedCulture); locale = model.MapLocaleTo(locale ?? new ProfileElementLocale { ProfileElement = profileElement }); localeService.Save(locale); Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId))); } } Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); return(View("Edit", model)); }
public virtual ActionResult ChangeLanguage(long profileElementId, String culture) { var profileElement = profileElementService.Find(profileElementId); if (profileElement == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty)); } ProfileElementViewModel model = new ProfileElementViewModel { ProfileTypeId = profileElement.ProfileHeader.Id }.MapFrom(profileElement); model.SelectedCulture = culture; //get locale var localeService = ServiceLocator.Current.GetInstance <IProfileElementLocaleService>(); ProfileElementLocale locale = localeService.GetLocale(profileElementId, culture); if (locale != null) { model.MapLocaleFrom(locale); } return(PartialView("ProfileElementDetails", model)); }
public ProfileElementViewModel MapLocaleFrom(ProfileElementLocale locale) { Title = locale.Title; Values = locale.ElementValues; SelectedCulture = locale.Culture; return(this); }
public ProfileElementLocale MapLocaleTo(ProfileElementLocale locale) { locale.Title = Title; locale.ElementValues = Values; if (SelectedCulture != null) { locale.Culture = SelectedCulture; } return(locale); }