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;
        }
        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;
        }
Esempio n. 3
0
        public ActionResult EditServerControlWidget(EditServerControlWidgetViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.ContentOptions != null && model.ContentOptions.GroupBy(o => o.OptionKey).SelectMany(g => g.Skip(1)).Any())
                {
                    Messages.AddError(PagesGlobalization.SaveWidget_DublicateOptionName_Message);
                    return Json(new WireJson { Success = false });
                }

                var response = GetCommand<SaveServerControlWidgetCommand>().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 });
        }
        public ActionResult EditServerControlWidget(EditServerControlWidgetViewModel model)
        {
            if (ModelState.IsValid)
            {
                var response = GetCommand<SaveServerControlWidgetCommand>().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 });
        }