示例#1
0
        public GetLayoutResponse Get(GetLayoutRequest request)
        {
            var model = repository
                .AsQueryable<Module.Root.Models.Layout>(layout => layout.Id == request.LayoutId)
                .Select(layout => new LayoutModel
                    {
                        Id = layout.Id,
                        Version = layout.Version,
                        CreatedBy = layout.CreatedByUser,
                        CreatedOn = layout.CreatedOn,
                        LastModifiedBy = layout.ModifiedByUser,
                        LastModifiedOn = layout.ModifiedOn,

                        Name = layout.Name,
                        LayoutPath = layout.LayoutPath,
                        PreviewUrl = layout.PreviewUrl
                    })
                .FirstOne();

            var response = new GetLayoutResponse { Data = model };

            if (request.Data.IncludeOptions)
            {
                response.Options = LayoutServiceHelper.GetLayoutOptionsList(repository, request.LayoutId);
            }

            if (request.Data.IncludeRegions)
            {
                response.Regions = LayoutServiceHelper.GetLayoutRegionsList(repository, request.LayoutId);
            }

            return response;
        }
示例#2
0
        public GetLayoutQuery Map(GetLayoutRequest request)
        {
            var id = new Guid(request.RouteId);

            var result = new GetLayoutQuery(id);

            return(result);
        }
示例#3
0
        public async Task <IActionResult> Produce(GetLayoutRequest request)
        {
            var validatorActionResult = await _validationArrangement.Validate(request);

            var actionResult = await _operationArrangement.Process(request, validatorActionResult);

            return(actionResult);
        }
        public async Task <IActionResult> Get([FromRoute] GetLayoutFromRoute route,
                                              [FromQuery] GetLayoutFromQuery query)
        {
            var request = new GetLayoutRequest(route, query);

            var result = await _apiResult.Produce(request);

            return(result);
        }
        public async Task<IActionResult> Process(GetLayoutRequest request, IValidatorActionResult validatorActionResult)
        {
            IActionResult actionResult;

            if (validatorActionResult.Result == null)
            {
                var call = _cqsMapper.Map(request);

                var result = await _mediator.Send(call);

                actionResult = result.IsFailure ? _apiResponse.Fail(result)
                                                : _apiResponse.Ok(((Result<LayoutModel>)result).Value, ((Result<LayoutModel>)result).Version.ToString());
            }
            else
            {
                actionResult = validatorActionResult.Result;
            }

            return actionResult;
        }
示例#6
0
        public GetLayoutResponse Get(GetLayoutRequest request)
        {
            var model = repository
                .AsQueryable<Module.Root.Models.Layout>(layout => layout.Id == request.LayoutId)
                .Select(layout => new LayoutModel
                    {
                        Id = layout.Id,
                        Version = layout.Version,
                        CreatedBy = layout.CreatedByUser,
                        CreatedOn = layout.CreatedOn,
                        LastModifiedBy = layout.ModifiedByUser,
                        LastModifiedOn = layout.ModifiedOn,

                        Name = layout.Name,
                        LayoutPath = layout.LayoutPath,
                        PreviewUrl = layout.PreviewUrl
                    })
                .FirstOne();

            return new GetLayoutResponse
                       {
                           Data = model
                       };
        }
        public void Synch_Crud_Examples()
        {
            using (var api = ApiFactory.Create())
            {
                // Tags:
                var tag = api.Root.Tag.Get(new GetTagRequest());
                api.Root.Tags.Post(tag.ToPostRequest());
                api.Root.Tag.Put(tag.ToPutRequest());
                api.Root.Tag.Delete(new DeleteTagRequest());

                // Categories:
                var category = api.Root.Category.Get(new GetCategoryRequest());
                api.Root.Categories.Post(category.ToPostRequest());
                api.Root.Category.Put(category.ToPutRequest());
                api.Root.Category.Delete(new DeleteCategoryRequest());

                // Layouts:
                var getLayoutRequest = new GetLayoutRequest();
                getLayoutRequest.Data.IncludeOptions = true;
                getLayoutRequest.Data.IncludeRegions = true;
                var layout = api.Root.Layout.Get(getLayoutRequest);
                api.Root.Layouts.Post(layout.ToPostRequest());
                api.Root.Layout.Put(layout.ToPutRequest());
                api.Root.Layout.Delete(new DeleteLayoutRequest());

                // Folders:
                var folder = api.Media.Folder.Get(new GetFolderRequest());
                api.Media.Folders.Post(folder.ToPostRequest());
                api.Media.Folder.Put(folder.ToPutRequest());
                api.Media.Folder.Delete(new DeleteFolderRequest());

                // Images:
                var image = api.Media.Image.Get(new GetImageRequest());
                api.Media.Images.Post(image.ToPostRequest());
                api.Media.Image.Put(image.ToPutRequest());
                api.Media.Image.Delete(new DeleteImageRequest());

                // Files:
                var file = api.Media.File.Get(new GetFileRequest());
                api.Media.Files.Post(file.ToPostRequest());
                api.Media.File.Put(file.ToPutRequest());
                api.Media.File.Delete(new DeleteFileRequest());

                // Languages:
                var language = api.Root.Language.Get(new GetLanguageRequest());
                api.Root.Languages.Post(language.ToPostRequest());
                api.Root.Language.Put(language.ToPutRequest());
                api.Root.Language.Delete(new DeleteLanguageRequest());

                // Redirects:
                var redirect = api.Pages.Redirect.Get(new GetRedirectRequest());
                api.Pages.Redirects.Post(redirect.ToPostRequest());
                api.Pages.Redirect.Put(redirect.ToPutRequest());
                api.Pages.Redirect.Delete(new DeleteRedirectRequest());

                // Server Widget:
                var getSWRequest = new GetServerControlWidgetRequest();
                getSWRequest.Data.IncludeOptions = true;
                var serverWidget = api.Pages.Widget.ServerControl.Get(getSWRequest);
                api.Pages.Widget.ServerControl.Post(serverWidget.ToPostRequest());
                api.Pages.Widget.ServerControl.Put(serverWidget.ToPutRequest());
                api.Pages.Widget.ServerControl.Delete(new DeleteServerControlWidgetRequest());

                // Html Widgets:
                var getHWRequest = new GetHtmlContentWidgetRequest();
                getHWRequest.Data.IncludeOptions = true;
                var htmlWidget = api.Pages.Widget.HtmlContent.Get(getHWRequest);
                api.Pages.Widget.HtmlContent.Post(htmlWidget.ToPostRequest());
                api.Pages.Widget.HtmlContent.Put(htmlWidget.ToPutRequest());
                api.Pages.Widget.HtmlContent.Delete(new DeleteHtmlContentWidgetRequest());

                // Html Contents:
                var html = api.Pages.Content.Html.Get(new GetHtmlContentRequest());
                // TODO: implement post.
                api.Pages.Content.Html.Put(html.ToPutRequest());
                api.Pages.Content.Html.Delete(new DeleteHtmlContentRequest());

                // Pages:
                var getPageRequest = new GetPagePropertiesRequest();
                getPageRequest.Data.IncludeAccessRules = true;
                getPageRequest.Data.IncludePageOptions = true;
                getPageRequest.Data.IncludeMetaData    = true;
                getPageRequest.Data.IncludeTags        = true;
                var page = api.Pages.Page.Properties.Get(getPageRequest);
                api.Pages.Page.Properties.Post(page.ToPostRequest());
                api.Pages.Page.Properties.Put(page.ToPutRequest());
                api.Pages.Page.Properties.Delete(new DeletePagePropertiesRequest());

                // Page Contents:
                var getPCrequest = new GetPageContentRequest();
                getPCrequest.Data.IncludeOptions = true; // Only when options should be retrieved and saved
                var pageContent = api.Pages.Page.Content.Get(getPCrequest);
                api.Pages.Page.Content.Put(pageContent.ToPutRequest());
                api.Pages.Page.Content.Delete(new DeletePageContentRequest());

                // Blog Post:
                var getBlogRequest = new GetBlogPostPropertiesRequest();
                getBlogRequest.Data.IncludeHtmlContent = true;
                getBlogRequest.Data.IncludeAccessRules = true;
                getBlogRequest.Data.IncludeMetaData    = true;
                getBlogRequest.Data.IncludeTags        = true;
                var blog = api.Blog.BlogPost.Properties.Get(getBlogRequest);
                api.Blog.BlogPost.Properties.Post(blog.ToPostRequest());
                api.Blog.BlogPost.Properties.Put(blog.ToPutRequest());
                api.Blog.BlogPost.Properties.Delete(new DeleteBlogPostPropertiesRequest());
                var author = api.Blog.Author.Get(new GetAuthorRequest());
                api.Blog.Authors.Post(author.ToPostRequest());
                api.Blog.Author.Put(author.ToPutRequest());
                api.Blog.Author.Delete(new DeleteAuthorRequest());
                var settings = api.Blog.Settings.Get(new GetBlogPostsSettingsRequest());
                api.Blog.Settings.Put(settings.ToPutRequest());

                // Sitemap:
                var sitemap = api.Pages.SitemapNew.Get(new GetSitemapRequest());
                api.Pages.Sitemaps.Post(sitemap.ToPostRequest());
                api.Pages.SitemapNew.Put(sitemap.ToPutRequest());
                api.Pages.SitemapNew.Delete(new DeleteSitemapRequest());

                // Sitemap nodes:
                var node = api.Pages.SitemapNew.Node.Get(new GetNodeRequest());
                api.Pages.SitemapNew.Nodes.Post(node.ToPostRequest());
                api.Pages.SitemapNew.Node.Put(node.ToPutRequest());
                api.Pages.SitemapNew.Node.Delete(new DeleteNodeRequest());

                // Destroyed draft (should be called on event BetterCms.Events.PageEvents.Instance.ContentDraftDestroyed)
                var destroyDraftRequest = new DestroyContentDraftRequest();
                // destroyDraftRequest.ContentId = contentId;
                api.Pages.Content.Draft.Delete(destroyDraftRequest);
            }
        }
示例#8
0
        public void Synch_Crud_Examples()
        {
            using (var api = ApiFactory.Create())
            {
                // Tags:
                var tag = api.Root.Tag.Get(new GetTagRequest());
                api.Root.Tags.Post(tag.ToPostRequest());
                api.Root.Tag.Put(tag.ToPutRequest());
                api.Root.Tag.Delete(new DeleteTagRequest());

                // Categories:
                var category = api.Root.Category.Get(new GetCategoryRequest());
                api.Root.Categories.Post(category.ToPostRequest());
                api.Root.Category.Put(category.ToPutRequest());
                api.Root.Category.Delete(new DeleteCategoryRequest());

                // Layouts:
                var getLayoutRequest = new GetLayoutRequest();
                getLayoutRequest.Data.IncludeOptions = true;
                getLayoutRequest.Data.IncludeRegions = true;
                var layout = api.Root.Layout.Get(getLayoutRequest);
                api.Root.Layouts.Post(layout.ToPostRequest());
                api.Root.Layout.Put(layout.ToPutRequest());
                api.Root.Layout.Delete(new DeleteLayoutRequest());

                // Folders:
                var folder = api.Media.Folder.Get(new GetFolderRequest());
                api.Media.Folders.Post(folder.ToPostRequest());
                api.Media.Folder.Put(folder.ToPutRequest());
                api.Media.Folder.Delete(new DeleteFolderRequest());

                // Images:
                var image = api.Media.Image.Get(new GetImageRequest());
                api.Media.Images.Post(image.ToPostRequest());
                api.Media.Image.Put(image.ToPutRequest());
                api.Media.Image.Delete(new DeleteImageRequest());

                // Files:
                var file = api.Media.File.Get(new GetFileRequest());
                api.Media.Files.Post(file.ToPostRequest());
                api.Media.File.Put(file.ToPutRequest());
                api.Media.File.Delete(new DeleteFileRequest());

                // Languages:
                var language = api.Root.Language.Get(new GetLanguageRequest());
                api.Root.Languages.Post(language.ToPostRequest());
                api.Root.Language.Put(language.ToPutRequest());
                api.Root.Language.Delete(new DeleteLanguageRequest());

                // Redirects:
                var redirect = api.Pages.Redirect.Get(new GetRedirectRequest());
                api.Pages.Redirects.Post(redirect.ToPostRequest());
                api.Pages.Redirect.Put(redirect.ToPutRequest());
                api.Pages.Redirect.Delete(new DeleteRedirectRequest());

                // Server Widget:
                var getSWRequest = new GetServerControlWidgetRequest();
                getSWRequest.Data.IncludeOptions = true;
                var serverWidget = api.Pages.Widget.ServerControl.Get(getSWRequest);
                api.Pages.Widget.ServerControl.Post(serverWidget.ToPostRequest());
                api.Pages.Widget.ServerControl.Put(serverWidget.ToPutRequest());
                api.Pages.Widget.ServerControl.Delete(new DeleteServerControlWidgetRequest());

                // Html Widgets:
                var getHWRequest = new GetHtmlContentWidgetRequest();
                getHWRequest.Data.IncludeOptions = true;
                var htmlWidget = api.Pages.Widget.HtmlContent.Get(getHWRequest);
                api.Pages.Widget.HtmlContent.Post(htmlWidget.ToPostRequest());
                api.Pages.Widget.HtmlContent.Put(htmlWidget.ToPutRequest());
                api.Pages.Widget.HtmlContent.Delete(new DeleteHtmlContentWidgetRequest());

                // Html Contents:
                var html = api.Pages.Content.Html.Get(new GetHtmlContentRequest());
                // TODO: implement post.
                api.Pages.Content.Html.Put(html.ToPutRequest());
                api.Pages.Content.Html.Delete(new DeleteHtmlContentRequest());

                // Pages:
                var getPageRequest = new GetPagePropertiesRequest();
                getPageRequest.Data.IncludeAccessRules = true;
                getPageRequest.Data.IncludePageOptions = true;
                getPageRequest.Data.IncludeMetaData = true;
                getPageRequest.Data.IncludeTags = true;
                var page = api.Pages.Page.Properties.Get(getPageRequest);
                api.Pages.Page.Properties.Post(page.ToPostRequest());
                api.Pages.Page.Properties.Put(page.ToPutRequest());
                api.Pages.Page.Properties.Delete(new DeletePagePropertiesRequest());

                // Page Contents:
                var getPCrequest = new GetPageContentRequest();
                getPCrequest.Data.IncludeOptions = true; // Only when options should be retrieved and saved
                var pageContent = api.Pages.Page.Content.Get(getPCrequest);
                api.Pages.Page.Content.Put(pageContent.ToPutRequest());
                api.Pages.Page.Content.Delete(new DeletePageContentRequest());

                // Blog Post:
                var getBlogRequest = new GetBlogPostPropertiesRequest();
                getBlogRequest.Data.IncludeHtmlContent = true;
                getBlogRequest.Data.IncludeAccessRules = true;
                getBlogRequest.Data.IncludeMetaData = true;
                getBlogRequest.Data.IncludeTags = true;
                var blog = api.Blog.BlogPost.Properties.Get(getBlogRequest);
                api.Blog.BlogPost.Properties.Post(blog.ToPostRequest());
                api.Blog.BlogPost.Properties.Put(blog.ToPutRequest());
                api.Blog.BlogPost.Properties.Delete(new DeleteBlogPostPropertiesRequest());
                var author = api.Blog.Author.Get(new GetAuthorRequest());
                api.Blog.Authors.Post(author.ToPostRequest());
                api.Blog.Author.Put(author.ToPutRequest());
                api.Blog.Author.Delete(new DeleteAuthorRequest());
                var settings = api.Blog.Settings.Get(new GetBlogPostsSettingsRequest());
                api.Blog.Settings.Put(settings.ToPutRequest());

                // Sitemap:
                var sitemap = api.Pages.SitemapNew.Get(new GetSitemapRequest());
                api.Pages.Sitemaps.Post(sitemap.ToPostRequest());
                api.Pages.SitemapNew.Put(sitemap.ToPutRequest());
                api.Pages.SitemapNew.Delete(new DeleteSitemapRequest());

                // Sitemap nodes:
                var node = api.Pages.SitemapNew.Node.Get(new GetNodeRequest());
                api.Pages.SitemapNew.Nodes.Post(node.ToPostRequest());
                api.Pages.SitemapNew.Node.Put(node.ToPutRequest());
                api.Pages.SitemapNew.Node.Delete(new DeleteNodeRequest());

                // Destroyed draft (should be called on event BetterCms.Events.PageEvents.Instance.ContentDraftDestroyed)
                var destroyDraftRequest = new DestroyContentDraftRequest();
                // destroyDraftRequest.ContentId = contentId;
                api.Pages.Content.Draft.Delete(destroyDraftRequest);
            }
        }