public virtual ActionResult ChangeLanguage(long pageId, String culture)
        {
            var page = pageService.Find(pageId);

            if (page == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "Page not found");
            }
            var        localeService = ServiceLocator.Current.GetInstance <IPageLocaleService>();
            PageLocale locale        = localeService.GetLocale(pageId, culture);
            String     pageTitle     = locale != null ? locale.Title : page.Title;
            var        serializer    = new JavaScriptSerializer();

            return(Content(serializer.Serialize(new { Title = pageTitle, Culture = culture })));
        }
        public virtual ActionResult UpdatePageCommonSettings(PageLocaleViewModel model)
        {
            if (ModelState.IsValid)
            {
                var page = new Page();
                page = pageService.Find(model.Id);
                if (!permissionService.IsAllowed((Int32)PageOperations.Update, this.CorePrincipal(), typeof(Page), model.Id, IsPageOwner(page), PermissionOperationLevel.Object))
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
                }
                var locales       = new JavaScriptSerializer().Deserialize <IDictionary <String, String> >(model.LocalesString);
                var localeService = ServiceLocator.Current.GetInstance <IPageLocaleService>();
                IList <PageLocale> pageLocales = localeService.GetLocales(page.Id);
                foreach (var locale in locales)
                {
                    PageLocale pageLocale = pageLocales.Where(pl => pl.Culture == locale.Key).FirstOrDefault();
                    if (pageLocale == null)
                    {
                        pageLocale = new PageLocale {
                            Page = page, Culture = locale.Key
                        };
                    }
                    pageLocale.Title = locale.Value;
                    localeService.Save(pageLocale);
                }
                if (pageService.Save(model.MapTo(page)))
                {
                    TempData["Success"] = true;
                }
                model = model.MapFrom(page);
            }
            else
            {
                Error(Translate("Messages.ValidationError"));
            }

            return(PartialView(MVC.Pages.Views.PageCommonSettings, model));
        }