示例#1
0
        public virtual ActionResult ChangeLanguage(long profileHeaderId, String culture)
        {
            var profileHeader = profileHeaderService.Find(profileHeaderId);

            if (profileHeader == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty));
            }


            ProfileHeaderViewModel model = new ProfileHeaderViewModel().MapFrom(profileHeader);

            model.SelectedCulture = culture;

            //get locale
            var localeService          = ServiceLocator.Current.GetInstance <IProfileHeaderLocaleService>();
            ProfileHeaderLocale locale = localeService.GetLocale(profileHeaderId, culture);

            if (locale != null)
            {
                model.MapLocaleFrom(locale);
            }

            return(PartialView("HeaderDetails", model));
        }
示例#2
0
        public ProfileHeaderViewModel MapLocaleFrom(ProfileHeaderLocale locale)
        {
            Title           = locale.Title;
            SelectedCulture = locale.Culture;

            return(this);
        }
示例#3
0
        public virtual ActionResult Save(long profileTypeId, ProfileHeaderViewModel model)
        {
            if (ModelState.IsValid)
            {
                var profileHeader = profileHeaderService.Find(model.Id);

                if (profileHeader == null)
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", String.Empty));
                }

                if (profileHeaderService.Save(model.MapTo(profileHeader)))
                {
                    //save locale
                    ProfileHeaderLocale locale = profileHeaderLocaleService.GetLocale(profileHeader.Id, model.SelectedCulture);
                    locale = model.MapLocaleTo(locale ?? new ProfileHeaderLocale {
                        ProfileHeader = profileHeader
                    });

                    profileHeaderLocaleService.Save(locale);

                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return(RedirectToAction(ProfilesMVC.ProfileElement.Show(profileTypeId)));
                }
            }
            else
            {
                Error(HttpContext.Translate("Messages.ValidationError", String.Empty));
            }

            return(View("Edit", model));
        }
示例#4
0
 public ProfileHeaderLocale MapLocaleTo(ProfileHeaderLocale locale)
 {
     locale.Title = Title;
     if (SelectedCulture != null)
     {
         locale.Culture = SelectedCulture;
     }
     return(locale);
 }