/// <summary> /// Shared basic data mapping assertions between <see cref="PageRenderSummary"/> /// query handler tests, which are expected to be using the same page /// construction schema. /// </summary> internal static void AssertBasicDataMapping( AddPageCommand addPageCommand, int versionId, PageRenderSummary page ) { page.Should().NotBeNull(); page.PageId.Should().Be(addPageCommand.OutputPageId); page.PageVersionId.Should().Be(versionId); page.CreateDate.Should().NotBeDefault(); page.PageRoute.Should().NotBeNull(); page.PageRoute.PageId.Should().Be(addPageCommand.OutputPageId); page.Should().NotBeNull(); page.OpenGraph.Should().NotBeNull(); page.OpenGraph.Title.Should().Be(addPageCommand.OpenGraphTitle); page.OpenGraph.Description.Should().Be(addPageCommand.OpenGraphDescription); page.OpenGraph.Image.Should().NotBeNull(); page.OpenGraph.Image.ImageAssetId.Should().Be(addPageCommand.OpenGraphImageId); page.MetaDescription.Should().Be(addPageCommand.MetaDescription); page.Title.Should().Be(addPageCommand.Title); page.PageVersionId.Should().Be(versionId); page.WorkFlowStatus.Should().Be(WorkFlowStatus.Published); }
internal static void AssertBasicDataMapping( string uniqueData, AddPageCommand addPageCommand, PageSummary page ) { var sluggedUniqueData = SlugFormatter.ToSlug(uniqueData); page.Should().NotBeNull(); page.PageId.Should().Be(addPageCommand.OutputPageId); page.AuditData.Should().NotBeNull(); page.AuditData.Creator.Should().NotBeNull(); page.AuditData.Creator.UserId.Should().BePositive(); page.FullUrlPath.Should().Be($"/{sluggedUniqueData}/{addPageCommand.UrlPath}"); page.Should().NotBeNull(); page.HasDraftVersion.Should().BeFalse(); page.Locale.Should().BeNull(); page.PageType.Should().Be(addPageCommand.PageType); page.PublishDate.Should().NotBeNull().And.NotBeDefault(); page.LastPublishDate.Should().NotBeNull().And.NotBeDefault(); page.PublishStatus.Should().Be(PublishStatus.Published); page.Tags.Should().ContainSingle(t => t == "Test"); page.Title.Should().Be(addPageCommand.Title); page.UrlPath.Should().Be(addPageCommand.UrlPath); }
/// <summary> /// Shared basic data mapping assertions between <see cref="PageRenderDetails"/> /// query handler tests, which are expected to be using the same page /// construction schema. /// </summary> internal static void AssertBasicDataMapping( AddPageCommand addPageCommand, int versionId, PageRenderDetails page ) { GetPageRenderSummaryByIdQueryHandlerTests.AssertBasicDataMapping(addPageCommand, versionId, page); page.Template.Should().NotBeNull(); page.Regions.Should().NotBeNull(); page.Regions.Should().HaveCount(1); }
/// <summary> /// Creates a valid <see cref="AddPageCommand"/> using a custom entity /// details page template and without the option to publish. The /// page will use the test custom entity details template which /// references the <see cref="TestCustomEntityDefinition"/>. /// </summary> /// <param name="uniqueData"> /// Unique data to use in creating the Title and UrlSlug property. /// </param> /// <param name="parentDirectoryId"> /// The database id of the page directory to use as the parent /// directory. /// </param> public AddPageCommand CreateAddCommandWithCustomEntityDetailsPage(string uniqueData, int parentDirectoryId) { var command = new AddPageCommand() { Title = uniqueData, PageDirectoryId = parentDirectoryId, PageType = PageType.CustomEntityDetails, PageTemplateId = _seededEntities.TestCustomEntityPageTemplate.PageTemplateId, CustomEntityRoutingRule = new IdAndUrlSlugCustomEntityRoutingRule().RouteFormat }; return(command); }
/// <summary> /// Creates a valid <see cref="AddPageCommand"/> using a generic page /// template and without the option to publish. /// </summary> /// <param name="uniqueData"> /// Unique data to use in creating the Title and UrlSlug property. /// </param> /// <param name="parentDirectoryId"> /// The database id of the page directory to use as the parent /// directory. /// </param> public AddPageCommand CreateAddCommand(string uniqueData, int parentDirectoryId) { var command = new AddPageCommand() { Title = uniqueData, PageDirectoryId = parentDirectoryId, UrlPath = SlugFormatter.ToSlug(uniqueData), PageType = PageType.Generic, PageTemplateId = _seededEntities.TestPageTemplate.PageTemplateId }; return(command); }
public void AddPage(string parentSubPath, string pageName) { var fileName = $"{pageName}.{Constants.ProjectItemFileExtensions.Page}"; var filePath = Path.Combine(Path.GetDirectoryName(_projectFilePath), parentSubPath, fileName); if (File.Exists(filePath)) { throw new ArgumentException($"A page named '{fileName}' already exists in this directory!"); } _cmdProcessor.Execute(AddPageCommand.Create(_outputService, _projectFilePath, parentSubPath, pageName)); ProjectItemChanged?.Invoke(new ProjectItemChangedArgs { ItemType = ProjectItemType.Page, Change = ProjectItemChange.Create, ItemName = pageName, ParentSubPath = parentSubPath }); }
private AddPageCommand MapCommand(DuplicatePageCommand command, PageQuery toDup) { EntityNotFoundException.ThrowIfNull(toDup, command.PageToDuplicateId); var addPageCommand = new AddPageCommand(); addPageCommand.ShowInSiteMap = !toDup.Version.ExcludeFromSitemap; addPageCommand.PageTemplateId = toDup.Version.PageTemplateId; addPageCommand.MetaDescription = toDup.Version.MetaDescription; addPageCommand.OpenGraphDescription = toDup.Version.OpenGraphDescription; addPageCommand.OpenGraphImageId = toDup.Version.OpenGraphImageId; addPageCommand.OpenGraphTitle = toDup.Version.OpenGraphTitle; addPageCommand.PageType = (PageType)toDup.PageTypeId; addPageCommand.Title = command.Title; addPageCommand.LocaleId = command.LocaleId; addPageCommand.UrlPath = command.UrlPath; addPageCommand.CustomEntityRoutingRule = command.CustomEntityRoutingRule; addPageCommand.PageDirectoryId = command.PageDirectoryId; addPageCommand.Tags = toDup.Tags.ToArray(); return(addPageCommand); }
public async Task <int> AddAsync(AddPageCommand command) { await ExtendableContentRepository.ExecuteCommandAsync(command); return(command.OutputPageId); }
public Task <Page> AddPageAsync(AddPageCommand command) { return(api.PostAsync <AddPageCommand, Page>(GetPagesPath(), command)); }
public async Task <IActionResult> Post([FromBody] AddPageCommand command) { return(await _apiResponseHelper.RunCommandAsync(this, command)); }
private void CreateNewAlbum() { Album.Reset(true); AddPageCommand.RaiseCanExecuteChanged(); }
public async Task <ActionResult <int> > AddPage([FromBody] AddPageCommand request) { return(Ok(await Mediator.Send(request))); }
public Task <JsonResult> Post([FromBody] AddPageCommand command) { return(_apiResponseHelper.RunCommandAsync(command)); }