Пример #1
0
        /// <summary>
        /// Executes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        /// <exception cref="ConcurrentDataException"></exception>
        /// <exception cref="CmsException"></exception>
        public DestroyContentDraftCommandResponse Execute(DestroyContentDraftCommandRequest request)
        {
            var content = draftService.DestroyDraftContent(request.Id, request.Version, Context.Principal);

            var response = new DestroyContentDraftCommandResponse
            {
                PublishedId     = content.Original.Id,
                Id              = content.Original.Id,
                OriginalId      = content.Original.Id,
                Version         = content.Original.Version,
                OriginalVersion = content.Original.Version,
                WidgetName      = content.Original.Name,
                IsPublished     = true,
                HasDraft        = false,
                DesirableStatus = ContentStatus.Published
            };

            // Try to cast to widget
            // TODO Widget categories
//            var widget = content.Original as HtmlContentWidget;
//            if (widget != null && widget.Category != null && !widget.Category.IsDeleted)
//            {
//                response.CategoryName = widget.Category.Name;
//            }

            if (request.IncludeChildRegions)
            {
                response.Regions = widgetService.GetWidgetChildRegionViewModels(content.Original);
            }

            return(response);
        }
        /// <summary>
        /// Executes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        /// <exception cref="ConcurrentDataException"></exception>
        /// <exception cref="CmsException"></exception>
        public DestroyContentDraftCommandResponse Execute(DestroyContentDraftCommandRequest request)
        {
            var content = draftService.DestroyDraftContent(request.Id, request.Version, Context.Principal);

            var response = new DestroyContentDraftCommandResponse
            {
                PublishedId     = content.Original.Id,
                Id              = content.Original.Id,
                OriginalId      = content.Original.Id,
                Version         = content.Original.Version,
                OriginalVersion = content.Original.Version,
                WidgetName      = content.Original.Name,
                IsPublished     = true,
                HasDraft        = false,
                DesirableStatus = ContentStatus.Published
            };

            // Try to cast to widget
            var widget = content.Original as HtmlContentWidget;

            if (widget != null && widget.Category != null && !widget.Category.IsDeleted)
            {
                response.CategoryName = widget.Category.Name;
            }

            return(response);
        }
Пример #3
0
        public DestroyContentDraftResponse Delete(DestroyContentDraftRequest request)
        {
            var version = request.Data != null ? request.Data.Version : 0;

            draftService.DestroyDraftContent(request.Id, version, securityService.GetCurrentPrincipal());

            return(new DestroyContentDraftResponse {
                Data = true
            });
        }