private static SaveServerControlWidgetModel MapServerControlWidgetModel(GetServerControlWidgetResponse response)
        {
            var model = new SaveServerControlWidgetModel
            {
                Version         = response.Data.Version,
                Name            = response.Data.Name,
                IsPublished     = response.Data.IsPublished,
                PublishedOn     = response.Data.PublishedOn,
                PublishedByUser = response.Data.PublishedByUser,
                CategoryId      = response.Data.CategoryId,
                PreviewUrl      = response.Data.PreviewUrl,
                WidgetUrl       = response.Data.WidgetUrl,
                Options         = response.Options
            };

            return(model);
        }
        public static EditServerControlWidgetViewModel ToServiceModel(this SaveServerControlWidgetModel model)
        {
            var serviceModel = new EditServerControlWidgetViewModel();

            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.Url             = model.WidgetUrl;
            serviceModel.PreviewImageUrl = model.PreviewUrl;

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

            return(serviceModel);
        }
Beispiel #3
0
        public static EditServerControlWidgetViewModel ToServiceModel(this SaveServerControlWidgetModel model)
        {
            var serviceModel = new EditServerControlWidgetViewModel();

            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.Url             = model.WidgetUrl;
            serviceModel.PreviewImageUrl = model.PreviewUrl;

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

            return(serviceModel);
        }