public ActionResult Translate(Guid id, string cultureCode)
        {
            if (!CheckPermission(NewsletterPermissions.ManageNewsletters))
            {
                return(new HttpUnauthorizedResult());
            }

            NewsletterModel model = newsletterService.GetByLanguage(id, cultureCode);

            WorkContext.Breadcrumbs.Add(T("Newsletters"), Url.Action("Index", new { area = Constants.Areas.Newsletters }));
            if (model != null)
            {
                WorkContext.Breadcrumbs.Add(model.Title);
            }

            WorkContext.Breadcrumbs.Add(T("Translate"));
            WorkContext.Breadcrumbs.Add(cultureCode);

            var showSaveAndContinue = false;

            if (model == null)
            {
                model                     = newsletterService.GetById(id);
                model.Id                  = Guid.Empty;
                model.CultureCode         = cultureCode;
                model.RefId               = id;
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(Guid.Empty, Guid.Empty.ToString(), null)
                };
            }
            else
            {
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(model.Id, model.Id.ToString(), null)
                };
                showSaveAndContinue = true;
            }

            var result = new ControlFormResult <NewsletterModel>(model)
            {
                Title                = T("Translate Newsletter").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AssignGridLayout(x => x.Id, 0, 0);
            result.AssignGridLayout(x => x.CultureCode, 0, 0);
            result.AssignGridLayout(x => x.RefId, 0, 0);
            result.AssignGridLayout(x => x.Title, 0, 0);
            result.AssignGridLayout(x => x.BodyContent, 0, 1, 2);

            if (showSaveAndContinue)
            {
                result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);
            }

            return(result);
        }
        public ActionResult Translate(int id, string cultureCode)
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            PageModel model = pageService.GetPageByLanguage(id, cultureCode);

            WorkContext.Breadcrumbs.Add(T("Pages"), Url.Action("Index", new { area = Constants.Areas.Pages }));
            if (model != null)
            {
                WorkContext.Breadcrumbs.Add(model.Title);
            }

            WorkContext.Breadcrumbs.Add(T("Translate"));
            WorkContext.Breadcrumbs.Add(cultureCode);

            var showSaveAndContinue = false;

            if (model == null)
            {
                model                     = pageService.GetById(id);
                model.Id                  = 0;
                model.CultureCode         = cultureCode;
                model.RefId               = id;
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(Guid.Empty, Guid.Empty.ToString(), null)
                };
            }
            else
            {
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(model.Id, model.Id.ToString(), null)
                };
                showSaveAndContinue = true;
            }

            var result = new ControlFormResult <PageModel>(model)
            {
                Title                = T("Translate Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AssignGridLayout(x => x.Id, 0, 0);
            result.AssignGridLayout(x => x.CultureCode, 0, 0);
            result.AssignGridLayout(x => x.RefId, 0, 0);
            result.AssignGridLayout(x => x.Title, 0, 0);
            result.AssignGridLayout(x => x.MetaKeywords, 1, 0);
            result.AssignGridLayout(x => x.IsEnabled, 0, 1);
            result.AssignGridLayout(x => x.MetaDescription, 1, 1);
            result.AssignGridLayout(x => x.BodyContent, 0, 2, 2);

            result.ExcludeProperty(x => x.Slug);
            result.AddHiddenValue("Slug", model.Slug);

            result.ExcludeProperty(x => x.Theme);
            result.AddHiddenValue("Theme", model.Theme);

            result.ExcludeProperty(x => x.CssClass);
            result.AddHiddenValue("CssClass", model.CssClass);

            result.ExcludeProperty(x => x.ShowOnMenuId);
            if (model.ShowOnMenuId.HasValue)
            {
                result.AddHiddenValue("ShowOnMenuId", model.ShowOnMenuId.Value.ToString());
            }

            if (showSaveAndContinue)
            {
                result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);
            }

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            return(result);
        }