public virtual ActionResult ChangeLanguage(long profileTypeId, String culture) { var profileType = profileTypeService.Find(profileTypeId); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } ProfileTypeViewModel model = new ProfileTypeViewModel().MapFrom(profileType); model.SelectedCulture = culture; //get locale var localeService = ServiceLocator.Current.GetInstance <IProfileTypeLocaleService>(); ProfileTypeLocale locale = localeService.GetLocale(profileTypeId, culture); if (locale != null) { model.MapLocaleFrom(locale); } return(PartialView("ProfileTypeDetails", model)); }
public virtual ActionResult Save(ProfileTypeViewModel model) { if (ModelState.IsValid) { var profileType = profileTypeService.Find(model.Id); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } if (profileTypeService.Save(model.MapTo(profileType))) { //save locale var localeService = ServiceLocator.Current.GetInstance <IProfileTypeLocaleService>(); ProfileTypeLocale locale = localeService.GetLocale(profileType.Id, model.SelectedCulture); locale = model.MapLocaleTo(locale ?? new ProfileTypeLocale { ProfileType = profileType }); localeService.Save(locale); Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(ProfilesMVC.ProfileType.Edit(model.Id))); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } return(View("Edit", model)); }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo) { ProfileTypeViewModel profileTypeViewModel = value as ProfileTypeViewModel; if (profileTypeViewModel == null) { return(new ValidationResult(false, "Profile type is required.")); } return(ValidationResult.ValidResult); }
public virtual ActionResult Show(long profileTypeId) { var profileType = profileTypesService.Find(profileTypeId); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty)); } var profileMembers = ProfileHelper.BindProfileElement(profileTypeId); ViewData["ProfileType"] = new ProfileTypeViewModel { Id = profileType.Id }; return View(profileMembers); }
public virtual ActionResult Show(long profileTypeId) { var profileType = profileTypesService.Find(profileTypeId); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty)); } var profileMembers = ProfileHelper.BindProfileElement(profileTypeId); ViewData["ProfileType"] = new ProfileTypeViewModel { Id = profileType.Id }; return(View(profileMembers)); }
public static ProfileType ToModel(this ProfileTypeViewModel profileTypeViewModel) { if (profileTypeViewModel == null) { throw new ArgumentNullException("profileTypeViewModel"); } ProfileType profileType = new ProfileType(); profileType.Id = profileTypeViewModel.Id; profileType.Name = profileTypeViewModel.Name; profileType.Thickness = profileTypeViewModel.Thickness; profileType.Shape = profileTypeViewModel.Shape; profileType.Length = profileTypeViewModel.Length; profileType.Weight = profileTypeViewModel.Weight; profileType.Price = profileTypeViewModel.Price; profileType.Tolerance = profileTypeViewModel.Tolerance; profileType.Description = profileTypeViewModel.Description; return(profileType); }
public virtual ActionResult New(ProfileTypeViewModel profileType) { if (ModelState.IsValid) { var newProfileType = profileType.MapTo(new ProfileType { UserId = this.CorePrincipal() != null ? this.CorePrincipal().PrincipalId : (long?)null, CreateDate = DateTime.Now }); if (profileTypeService.Save(newProfileType)) { Success(HttpContext.Translate("Messages.Success", String.Empty)); return(RedirectToAction(ProfilesMVC.ProfileType.Edit(newProfileType.Id))); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } return(View("New", profileType)); }
public virtual ActionResult New(ProfileTypeViewModel profileType) { if (ModelState.IsValid) { var newProfileType = profileType.MapTo(new ProfileType { UserId = this.CorePrincipal() != null ? this.CorePrincipal().PrincipalId : (long?)null, CreateDate = DateTime.Now }); if (profileTypeService.Save(newProfileType)) { Success(HttpContext.Translate("Messages.Success", String.Empty)); return RedirectToAction(ProfilesMVC.ProfileType.Edit(newProfileType.Id)); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } return View("New", profileType); }
public virtual ActionResult Save(ProfileTypeViewModel model) { if (ModelState.IsValid) { var profileType = profileTypeService.Find(model.Id); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } if (profileTypeService.Save(model.MapTo(profileType))) { //save locale var localeService = ServiceLocator.Current.GetInstance<IProfileTypeLocaleService>(); ProfileTypeLocale locale = localeService.GetLocale(profileType.Id, model.SelectedCulture); locale = model.MapLocaleTo(locale ?? new ProfileTypeLocale { ProfileType = profileType }); localeService.Save(locale); Success(HttpContext.Translate("Messages.Success", String.Empty)); return RedirectToAction(ProfilesMVC.ProfileType.Edit(model.Id)); } } else { Error(HttpContext.Translate("Messages.ValidationError", String.Empty)); } return View("Edit", model); }
public virtual ActionResult ChangeLanguage(long profileTypeId, String culture) { var profileType = profileTypeService.Find(profileTypeId); if (profileType == null) { throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this))); } ProfileTypeViewModel model = new ProfileTypeViewModel().MapFrom(profileType); model.SelectedCulture = culture; //get locale var localeService = ServiceLocator.Current.GetInstance<IProfileTypeLocaleService>(); ProfileTypeLocale locale = localeService.GetLocale(profileTypeId, culture); if (locale != null) model.MapLocaleFrom(locale); return PartialView("ProfileTypeDetails", model); }