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 New(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 = model.MapTo(new ProfileElement()); profileElement.OrderNumber = profileElementService.GetLastOrderNumber(profileElement.ProfileHeader.Id); if (profileElementService.Save(profileElement)) { Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId))); } } Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); return(View("New", model)); }
public virtual ActionResult New(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 = model.MapTo(new ProfileElement()); profileElement.OrderNumber = profileElementService.GetLastOrderNumber(profileElement.ProfileHeader.Id); if (profileElementService.Save(profileElement)) { Success(HttpContext.Translate("Messages.Success", String.Empty)); return RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId)); } } Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); return View("New", model); }
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); }