public static EditHtmlContentWidgetViewModel ToServiceModel(this SaveHtmlContentWidgetModel model)
        {
            var serviceModel = new EditHtmlContentWidgetViewModel();

            serviceModel.Version = model.Version;
            serviceModel.Name = model.Name;
            serviceModel.DesirableStatus = model.IsPublished ? ContentStatus.Published : ContentStatus.Draft;
            serviceModel.PublishedOn = model.PublishedOn;
            serviceModel.PublishedByUser = model.PublishedByUser;
            serviceModel.Categories = model.Categories != null ? model.Categories.Select(c => new LookupKeyValue()
            {
                Key = c.ToString(),
            }).ToList() : new List<LookupKeyValue>();

            serviceModel.CustomCSS = model.CustomCss;
            serviceModel.EnableCustomCSS = model.UseCustomCss;
            serviceModel.PageContent = model.Html;
            serviceModel.EnableCustomHtml = model.UseHtml;
            serviceModel.CustomJS = model.CustomJavaScript;
            serviceModel.EnableCustomJS = model.UseCustomJavaScript;

            if (model.Options != null)
            {
                serviceModel.Options = model.Options.ToServiceModel();
            }

            return serviceModel;
        }
        public static EditHtmlContentWidgetViewModel ToServiceModel(this SaveHtmlContentWidgetModel model)
        {
            var serviceModel = new EditHtmlContentWidgetViewModel();

            serviceModel.Version = model.Version;
            serviceModel.Name = model.Name;
            serviceModel.DesirableStatus = model.IsPublished ? ContentStatus.Published : ContentStatus.Draft;
            serviceModel.PublishedOn = model.PublishedOn;
            serviceModel.PublishedByUser = model.PublishedByUser;
            serviceModel.CategoryId = model.CategoryId;
            serviceModel.CustomCSS = model.CustomCss;
            serviceModel.EnableCustomCSS = model.UseCustomCss;
            serviceModel.PageContent = model.Html;
            serviceModel.EnableCustomHtml = model.UseHtml;
            serviceModel.CustomJS = model.CustomJavaScript;
            serviceModel.EnableCustomJS = model.UseCustomJavaScript;

            if (model.Options != null)
            {
                serviceModel.Options = model.Options.ToServiceModel();
            }

            return serviceModel;
        }
Example #3
0
        public ActionResult EditHtmlContentWidget(EditHtmlContentWidgetViewModel model)
        {
            if (ModelState.IsValid)
            {
                var response = GetCommand<SaveHtmlContentWidgetCommand>().ExecuteCommand(model);
                if (response != null)
                {
                    if (model.Id.HasDefaultValue())
                    {
                        Messages.AddSuccess(PagesGlobalization.SaveWidget_CreatedSuccessfully_Message);
                    }

                    return Json(new WireJson { Success = true, Data = response });
                }
            }

            return Json(new WireJson { Success = false });
        }