Browse Source

Added content property to BlogPost and ui

pull/7911/head
Ahmet 5 years ago
parent
commit
6c356a8288
  1. 2016
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210302075529_Added_Content_To_BlogPost.Designer.cs
  2. 24
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210302075529_Added_Content_To_BlogPost.cs
  3. 4
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 5
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs
  5. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs
  6. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs
  7. 5
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
  8. 28
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml
  9. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs
  10. 29
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml
  11. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs
  12. 109
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js
  13. 132
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js
  14. 2
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs
  15. 16
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs
  16. 6
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs
  17. 8
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  18. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs
  19. 6
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPost/Default.cshtml
  20. 14
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs
  21. 6
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs

2016
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210302075529_Added_Content_To_BlogPost.Designer.cs

File diff suppressed because it is too large

24
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210302075529_Added_Content_To_BlogPost.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Added_Content_To_BlogPost : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Content",
table: "CmsBlogPosts",
type: "nvarchar(max)",
maxLength: 2147483647,
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Content",
table: "CmsBlogPosts");
}
}
}

4
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

@ -1269,6 +1269,10 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Content")
.HasMaxLength(2147483647)
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");

5
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostDto.cs

@ -11,6 +11,9 @@ namespace Volo.CmsKit.Admin.Blogs
public string Title { get; set; }
public string Slug { get; set; }
public string ShortDescription { get; protected set; }
public string ShortDescription { get; set; }
public string Content { get; set; }
}
}

3
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/CreateBlogPostDto.cs

@ -21,5 +21,8 @@ namespace Volo.CmsKit.Admin.Blogs
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))]
public string ShortDescription { get; set; }
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))]
public string Content { get; set; }
}
}

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/UpdateBlogPostDto.cs

@ -18,6 +18,8 @@ namespace Volo.CmsKit.Admin.Blogs
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))]
public string ShortDescription { get; set; }
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))]
public string Content { get; set; }
}
}

5
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs

@ -54,7 +54,7 @@ namespace Volo.CmsKit.Admin.Blogs
input.Title,
input.Slug,
input.ShortDescription,
CurrentTenant.Id);
input.Content);
await BlogPostRepository.InsertAsync(blogPost);
@ -68,7 +68,8 @@ namespace Volo.CmsKit.Admin.Blogs
blogPost.SetTitle(input.Title);
blogPost.SetShortDescription(input.ShortDescription);
blogPost.SetContent(input.Content);
if (blogPost.Slug != input.Slug)
{
await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug);

28
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml

@ -1,5 +1,7 @@
@page
@using System.Globalization
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.TuiEditor
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Contents.Components.EntityContentEditor
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar
@using Volo.CmsKit.Admin.Web.Pages
@ -22,12 +24,19 @@
@section scripts {
<abp-script-bundle>
<abp-script type="typeof(UppyScriptContributor)" />
<abp-script src="/Pages/CmsKit/BlogPosts/create.js" />
<abp-script type="typeof(SlugifyScriptContributor)" />
<abp-script type="typeof(TuiEditorScriptContributor)"/>
<abp-script type="typeof(UppyScriptContributor)"/>
<abp-script type="typeof(SlugifyScriptContributor)"/>
<abp-script src="/Pages/CmsKit/BlogPosts/create.js"/>
</abp-script-bundle>
}
@section styles {
<abp-style-bundle>
<abp-style type="typeof(TuiEditorStyleContributor)"/>
</abp-style-bundle>
}
@section content_toolbar {
@await Component.InvokeAsync(typeof(AbpPageToolbarViewComponent), new { pageName = typeof(CreateModel).FullName })
}
@ -50,15 +59,14 @@
<abp-input asp-for="ViewModel.Title" />
<abp-input asp-for="ViewModel.Slug" />
@await Component.InvokeAsync(typeof(EntityContentEditorViewComponent), new
{
entityType = BlogPostConsts.EntityType,
displaySubmitButton = false
})
<abp-form-content />
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
</abp-dynamic-form>
<div id="blog-post-tags-wrapper">

4
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Create.cshtml.cs

@ -58,6 +58,10 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))]
public string ShortDescription { get; set; }
[HiddenInput]
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))]
public string Content { get; set; }
}
}
}

29
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml

@ -1,5 +1,7 @@
@page "{Id}"
@using System.Globalization
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.TuiEditor
@using Volo.CmsKit.Blogs
@using Volo.CmsKit.Admin.Web.Pages
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar
@ -22,12 +24,19 @@
@section scripts {
<abp-script-bundle>
<abp-script type="typeof(UppyScriptContributor)" />
<abp-script src="/Pages/CmsKit/BlogPosts/update.js" />
<abp-script type="typeof(SlugifyScriptContributor)" />
<abp-script type="typeof(TuiEditorScriptContributor)"/>
<abp-script type="typeof(UppyScriptContributor)"/>
<abp-script type="typeof(SlugifyScriptContributor)"/>
<abp-script src="/Pages/CmsKit/BlogPosts/update.js"/>
</abp-script-bundle>
}
@section styles {
<abp-style-bundle>
<abp-style type="typeof(TuiEditorStyleContributor)"/>
</abp-style-bundle>
}
@section content_toolbar {
@await Component.InvokeAsync(typeof(AbpPageToolbarViewComponent), new { pageName = typeof(UpdateModel).FullName })
}
@ -49,14 +58,14 @@
<abp-input asp-for="ViewModel.Slug" />
@await Component.InvokeAsync(typeof(EntityContentEditorViewComponent), new
{
entityType = BlogPostConsts.EntityType,
entityId = Model.Id.ToString(),
displaySubmitButton = false
})
<abp-form-content />
<div class="content-editor"
id="ContentEditor"
data-input-id="@Html.IdFor(x => x.ViewModel.Content)"
data-language="@(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)">
</div>
</abp-dynamic-form>
@if (Model.TagsFeature?.IsEnabled == true)

4
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/Update.cshtml.cs

@ -72,6 +72,10 @@ namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.BlogPosts
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxShortDescriptionLength))]
[DisplayOrder(10001)]
public string ShortDescription { get; set; }
[HiddenInput]
[DynamicMaxLength(typeof(BlogPostConsts), nameof(BlogPostConsts.MaxContentLength))]
public string Content { get; set; }
}
}
}

109
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/create.js

@ -41,7 +41,12 @@
$formCreate.ajaxSubmit({
success: function (result) {
submitEntityContent(result.id);
if (isTagsEnabled) {
submitEntityTags(result.id);
}
else {
submitCoverImage(result.id);
}
},
error: function (result) {
abp.notify.error(result.responseJSON.error.message);
@ -55,29 +60,16 @@
e.preventDefault();
$formCreate.submit();
});
function submitEntityContent(blogPostId) {
volo.cmsKit.admin.contents.contentAdmin
.create(
{
entityType: 'BlogPost',
entityId: blogPostId,
value: $pageContentInput.val()
})
.then(function (result) {
if (isTagsEnabled) {
submitEntityTags(blogPostId)
}
else {
submitCoverImage(blogPostId);
}
});
}
function submitEntityTags(blogPostId) {
var tags = $tagsInput.val().split(",");
var tags = $tagsInput.val().split(',').map(x => x.trim()).filter(x => x);
if(tags.length === 0){
submitCoverImage(blogPostId);
return;
}
volo.cmsKit.admin.tags.entityTagAdmin
.setEntityTags({
entityType: 'BlogPost',
@ -209,4 +201,77 @@
}
});
});
// -----------------------------------
var fileUploadUri = "/api/cms-kit-admin/media/blogpost";
var fileUriPrefix = "/api/cms-kit/media/";
var editorDataKey = "tuiEditor";
initAllEditors();
function initAllEditors() {
$('.content-editor').each(function (i, item) {
initEditor(item);
});
}
function initEditor(element) {
var $editorContainer = $(element);
var inputName = $editorContainer.data('input-id');
var $editorInput = $('#' + inputName);
var initialValue = $editorInput.val();
var editor = $editorContainer.tuiEditor({
usageStatistics: false,
useCommandShortcut: true,
initialValue: initialValue,
previewStyle: 'tab',
height: "25em",
minHeight: "25em",
initialEditType: initialValue ? 'wysiwyg' : 'markdown',
language: $editorContainer.data("language"),
hooks: {
addImageBlobHook: uploadFile,
},
events: {
change: function (_val) {
$editorInput.val(editor.getHtml());
$editorInput.trigger("change");
}
}
}).data(editorDataKey);
}
function uploadFile(blob, callback, source) {
var UPPY_OPTIONS = {
endpoint: fileUploadUri,
formData: true,
fieldName: "file",
method: "post",
headers: getUppyHeaders()
};
var UPPY = Uppy.Core().use(Uppy.XHRUpload, UPPY_OPTIONS);
UPPY.reset();
UPPY.addFile({
id: "content-file",
name: blob.name,
type: blob.type,
data: blob,
});
UPPY.upload().then((result) => {
if (result.failed.length > 0) {
abp.message.error("File upload failed");
} else {
var mediaDto = result.successful[0].response.body;
var fileUrl = (fileUriPrefix + mediaDto.id);
callback(fileUrl, mediaDto.name);
}
});
}
});

132
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/update.js

@ -8,15 +8,15 @@
var $titleClone = $('#title-clone');
var $slug = $('#ViewModel_Slug');
var $buttonSubmit = $('#button-blog-post-update');
var $contentValueInput = $('#ViewModel_Value');
var $blogPostIdInput = $('#Id');
var $contentIdInput = $('#ViewModel_Id');
var $tagsInput = $('.tag-editor-form input[name=tags]');
var $fileInput = $('#BlogPostCoverImage');
var UPPY_UPLOAD_ENDPOINT = "/api/cms-kit-admin/blogs/blog-posts/{0}/cover-image";
var UPPY_FILE_ID = "uppy-upload-file";
var isTagsEnabled = true;
$formUpdate.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper";
function initSelectBlog() {
@ -40,7 +40,12 @@
$formUpdate.ajaxSubmit({
success: function (result) {
submitEntityContent();
if (isTagsEnabled) {
submitEntityTags($blogPostIdInput.val());
}
else {
submitCoverImage($blogPostIdInput.val());
}
},
error: function (result) {
abp.ui.clearBusy(); abp.notify.error(result.responseJSON.error.message);
@ -53,49 +58,16 @@
e.preventDefault();
$formUpdate.submit();
});
function submitEntityTags(blogPostId) {
function submitEntityContent() {
var contentId = $contentIdInput.val();
var blogPostId = $blogPostIdInput.val();
var contentValue = $contentValueInput.val();
if (contentId) {
volo.cmsKit.admin.contents.contentAdmin
.update(contentId,
{
value: contentValue
})
.then(function (result) {
entityContentCallback(blogPostId);
});
}
else {
volo.cmsKit.admin.contents.contentAdmin
.create({
entityType: 'BlogPost',
entityId: blogPostId,
value: contentValue
})
.then(function (result) {
entityContentCallback(blogPostId);
});
}
}
var tags = $tagsInput.val().split(',').map(x => x.trim()).filter(x => x);
function entityContentCallback(blogPostId) {
if ($tagsInput.val()) {
submitEntityTags(blogPostId);
}
else {
if(tags.length === 0){
submitCoverImage(blogPostId);
return;
}
}
function submitEntityTags(blogPostId) {
var tags = $tagsInput.val().split(",");
volo.cmsKit.admin.tags.entityTagAdmin
.setEntityTags({
entityType: 'BlogPost',
@ -154,7 +126,7 @@
function finishSaving(result) {
abp.notify.success(l('SuccessfullySaved'));
abp.ui.clearBusy();
location.href = "../BlogPosts/";
location.href = "/CmsKit/BlogPosts/";
}
$titleClone.on('change paste keyup', function () {
@ -177,4 +149,78 @@
});
}
}
// -----------------------------------
var fileUploadUri = "/api/cms-kit-admin/media/blogpost";
var fileUriPrefix = "/api/cms-kit/media/";
var editorDataKey = "tuiEditor";
initAllEditors();
function initAllEditors() {
$('.content-editor').each(function (i, item) {
initEditor(item);
});
}
function initEditor(element) {
var $editorContainer = $(element);
var inputName = $editorContainer.data('input-id');
var $editorInput = $('#' + inputName);
var initialValue = $editorInput.val();
var editor = $editorContainer.tuiEditor({
usageStatistics: false,
useCommandShortcut: true,
initialValue: initialValue,
previewStyle: 'tab',
height: "25em",
minHeight: "25em",
initialEditType: initialValue ? 'wysiwyg' : 'markdown',
language: $editorContainer.data("language"),
hooks: {
addImageBlobHook: uploadFile,
},
events: {
change: function (_val) {
$editorInput.val(editor.getHtml());
$editorInput.trigger("change");
}
}
}).data(editorDataKey);
}
function uploadFile(blob, callback, source) {
var UPPY_OPTIONS = {
endpoint: fileUploadUri,
formData: true,
fieldName: "file",
method: "post",
headers: getUppyHeaders()
};
var UPPY = Uppy.Core().use(Uppy.XHRUpload, UPPY_OPTIONS);
UPPY.reset();
UPPY.addFile({
id: "content-file",
name: blob.name,
type: blob.type,
data: blob,
});
UPPY.upload().then((result) => {
if (result.failed.length > 0) {
abp.message.error("File upload failed");
} else {
var mediaDto = result.successful[0].response.body;
var fileUrl = (fileUriPrefix + mediaDto.id);
callback(fileUrl, mediaDto.name);
}
});
}
});

2
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs

@ -11,6 +11,8 @@ namespace Volo.CmsKit.Blogs
public static int MinSlugLength { get; set; } = 2;
public static int MaxShortDescriptionLength { get; set; } = 256;
public static int MaxContentLength { get; set; } = int.MaxValue;
public const string EntityType = "BlogPost";
}

16
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs

@ -21,9 +21,10 @@ namespace Volo.CmsKit.Blogs
[NotNull]
public virtual string ShortDescription { get; protected set; }
public virtual string Content { get; protected set; }
public virtual Guid? TenantId { get; protected set; }
[NotNull]
public Guid AuthorId { get; set; }
public virtual CmsUser Author { get; set; }
@ -38,13 +39,17 @@ namespace Volo.CmsKit.Blogs
Guid authorId,
[NotNull] string title,
[NotNull] string slug,
[CanBeNull] string shortDescription = null) : base(id)
[CanBeNull] string shortDescription = null,
[CanBeNull] string content = null,
[CanBeNull] Guid? tenantId = null) : base(id)
{
TenantId = tenantId;
BlogId = blogId;
AuthorId = authorId;
SetTitle(title);
SetSlug(slug);
ShortDescription = shortDescription;
SetShortDescription(shortDescription);
SetContent(content);
}
public virtual void SetTitle(string title)
@ -63,5 +68,10 @@ namespace Volo.CmsKit.Blogs
{
ShortDescription = Check.Length(shortDescription, nameof(shortDescription), BlogPostConsts.MaxShortDescriptionLength);
}
public virtual void SetContent(string content)
{
Content = Check.Length(content, nameof(content), BlogPostConsts.MaxContentLength);
}
}
}

6
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs

@ -27,7 +27,7 @@ namespace Volo.CmsKit.Blogs
[NotNull] string title,
[NotNull] string slug,
[CanBeNull] string shortDescription = null,
[CanBeNull] Guid? tenantId = null)
[CanBeNull] string content = null)
{
Check.NotNull(author, nameof(author));
Check.NotNull(blog, nameof(blog));
@ -42,7 +42,9 @@ namespace Volo.CmsKit.Blogs
author.Id,
title,
slug,
shortDescription
shortDescription,
content,
CurrentTenant.Id
);
await CheckSlugExistenceAsync(blog.Id, blogPost.Slug);

8
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -207,14 +207,12 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ConfigureByConvention();
b.Property(p => p.AuthorId).IsRequired();
b.Property(p => p.Title).IsRequired().HasMaxLength(BlogPostConsts.MaxTitleLength);
b.Property(p => p.Slug).IsRequired().HasMaxLength(BlogPostConsts.MaxSlugLength);
b.Property(p => p.ShortDescription).HasMaxLength(BlogPostConsts.MaxShortDescriptionLength);
b.Property(p => p.AuthorId).IsRequired();
b.Property(p => p.Content).HasMaxLength(BlogPostConsts.MaxContentLength);
b.HasIndex(x => new { x.Slug, x.BlogId });
});

2
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostPublicDto.cs

@ -15,6 +15,8 @@ namespace Volo.CmsKit.Public.Blogs
public string ShortDescription { get; set; }
public string Content { get; set; }
public CmsUserDto Author { get; set; }
}
}

6
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Blogs/BlogPost/Default.cshtml

@ -14,11 +14,7 @@
</abp-card-header>
<abp-card-body>
@await Component.InvokeAsync(typeof(ContentViewComponent), new
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.Id.ToString()
})
@Html.Raw(Model.Content)
</abp-card-body>
<abp-card-footer>
<abp-card-subtitle>@Model.CreationTime</abp-card-subtitle>

14
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostAdminAppService_Tests.cs

@ -30,13 +30,15 @@ namespace Volo.CmsKit.Blogs
var title = "My awesome new Post";
var slug = "my-awesome-new-post";
var shortDescription = "This blog is all about awesomeness 🤗!";
var content = "Another blog post shared on internet";
var created = await blogPostAdminAppService.CreateAsync(new CreateBlogPostDto
{
BlogId = cmsKitTestData.Blog_Id,
Title = title,
Slug = slug,
ShortDescription = shortDescription
ShortDescription = shortDescription,
Content = content
});
created.Id.ShouldNotBe(Guid.Empty);
@ -46,6 +48,7 @@ namespace Volo.CmsKit.Blogs
blogPost.Title.ShouldBe(title);
blogPost.Slug.ShouldBe(slug);
blogPost.ShortDescription.ShouldBe(shortDescription);
blogPost.Content.ShouldBe(content);
}
[Fact]
@ -54,6 +57,7 @@ namespace Volo.CmsKit.Blogs
var title = "Another My Awesome New Post";
var slug = "another-my-awesome-new-post";
var shortDescription = "This blog is all about awesomeness 🤗!";
var content = "Another blog post shared on internet";
var dto = new CreateBlogPostDto
{
@ -61,7 +65,8 @@ namespace Volo.CmsKit.Blogs
BlogId = Guid.NewGuid(),
Title = title,
Slug = slug,
ShortDescription = shortDescription
ShortDescription = shortDescription,
Content = content
};
var exception = await Should.ThrowAsync<EntityNotFoundException>(async () =>
@ -107,12 +112,14 @@ namespace Volo.CmsKit.Blogs
var shortDescription = "Another short description";
var title = "[Solved] Another Blog Post";
var slug = "another-short-blog-post";
var content = "Another blog post shared on internet";
await blogPostAdminAppService.UpdateAsync(cmsKitTestData.BlogPost_2_Id, new UpdateBlogPostDto
{
ShortDescription = shortDescription,
Title = title,
Slug = slug,
Content = content
});
var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_2_Id);
@ -120,6 +127,7 @@ namespace Volo.CmsKit.Blogs
blogPost.Title.ShouldBe(title);
blogPost.ShortDescription.ShouldBe(shortDescription);
blogPost.Slug.ShouldBe(slug);
blogPost.Content.ShouldBe(content);
}
[Fact]

6
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs

@ -367,7 +367,8 @@ namespace Volo.CmsKit
blog,
_cmsKitTestData.BlogPost_1_Title,
_cmsKitTestData.BlogPost_1_Slug,
"Short desc 1"))).Id;
"Short desc 1",
"Blog Post 1 Content"))).Id;
_cmsKitTestData.BlogPost_2_Id =
(await _blogPostRepository.InsertAsync(
@ -376,7 +377,8 @@ namespace Volo.CmsKit
blog,
_cmsKitTestData.BlogPost_2_Title,
_cmsKitTestData.BlogPost_2_Slug,
"Short desc 2"))).Id;
"Short desc 2",
"Blog Post 2 Content"))).Id;
}
private async Task SeedBlogFeaturesAsync()

Loading…
Cancel
Save