Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static SaveHtmlContentWidgetModel MapHtmlContentWidgetModel(GetHtmlContentWidgetResponse response)
        {
            var model = new SaveHtmlContentWidgetModel
            {
                Version                   = response.Data.Version,
                Name                      = response.Data.Name,
                IsPublished               = response.Data.IsPublished,
                PublishedOn               = response.Data.PublishedOn,
                PublishedByUser           = response.Data.PublishedByUser,
                CategoryId                = response.Data.CategoryId,
                CustomCss                 = response.Data.CustomCss,
                UseCustomCss              = response.Data.UseCustomCss,
                Html                      = response.Data.Html,
                UseHtml                   = response.Data.UseHtml,
                CustomJavaScript          = response.Data.CustomJavaScript,
                UseCustomJavaScript       = response.Data.UseCustomJavaScript,
                Options                   = response.Options,
                ChildContentsOptionValues = response.ChildContentsOptionValues
            };

            return(model);
        }
        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);
        }