|
|
|
@ -1,8 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using System; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
|
|
|
|
@ -10,35 +9,37 @@ namespace Volo.CmsKit.Blogs |
|
|
|
{ |
|
|
|
public class BlogPostManager : DomainService, IBlogPostManager |
|
|
|
{ |
|
|
|
protected readonly IBlogPostRepository blogPostRepository; |
|
|
|
protected readonly IBlogRepository blogRepository; |
|
|
|
protected IBlogPostRepository BlogPostRepository { get; } |
|
|
|
protected IBlogRepository BlogRepository { get; } |
|
|
|
|
|
|
|
public BlogPostManager( |
|
|
|
IBlogPostRepository blogPostRepository, |
|
|
|
IBlogRepository blogRepository) |
|
|
|
{ |
|
|
|
this.blogPostRepository = blogPostRepository; |
|
|
|
this.blogRepository = blogRepository; |
|
|
|
BlogPostRepository = blogPostRepository; |
|
|
|
BlogRepository = blogRepository; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<BlogPost> CreateAsync(BlogPost blogPost) |
|
|
|
public virtual async Task<BlogPost> CreateAsync(BlogPost blogPost) |
|
|
|
{ |
|
|
|
await CheckBlogExistenceAsync(blogPost.BlogId); |
|
|
|
|
|
|
|
await CheckSlugExistenceAsync(blogPost.BlogId, blogPost.Slug); |
|
|
|
|
|
|
|
return await blogPostRepository.InsertAsync(blogPost); |
|
|
|
return await BlogPostRepository.InsertAsync(blogPost); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task UpdateAsync(BlogPost blogPost) |
|
|
|
public virtual async Task UpdateAsync(BlogPost blogPost) |
|
|
|
{ |
|
|
|
await CheckBlogExistenceAsync(blogPost.BlogId); |
|
|
|
|
|
|
|
await blogPostRepository.UpdateAsync(blogPost); |
|
|
|
await BlogPostRepository.UpdateAsync(blogPost); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task SetSlugUrlAsync(BlogPost blogPost, string newSlug) |
|
|
|
public virtual async Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug) |
|
|
|
{ |
|
|
|
Check.NotNullOrWhiteSpace(newSlug, nameof(newSlug)); |
|
|
|
|
|
|
|
await CheckSlugExistenceAsync(blogPost.BlogId, newSlug); |
|
|
|
|
|
|
|
blogPost.SetSlug(newSlug); |
|
|
|
@ -46,7 +47,7 @@ namespace Volo.CmsKit.Blogs |
|
|
|
|
|
|
|
private async Task CheckSlugExistenceAsync(Guid blogId, string slug) |
|
|
|
{ |
|
|
|
if (await blogPostRepository.SlugExistsAsync(blogId, slug)) |
|
|
|
if (await BlogPostRepository.SlugExistsAsync(blogId, slug)) |
|
|
|
{ |
|
|
|
throw new BlogPostSlugAlreadyExistException(blogId, slug); |
|
|
|
} |
|
|
|
@ -54,7 +55,7 @@ namespace Volo.CmsKit.Blogs |
|
|
|
|
|
|
|
private async Task CheckBlogExistenceAsync(Guid blogId) |
|
|
|
{ |
|
|
|
if (!await blogRepository.ExistsAsync(blogId)) |
|
|
|
if (!await BlogRepository.ExistsAsync(blogId)) |
|
|
|
throw new EntityNotFoundException(typeof(Blog), blogId); |
|
|
|
} |
|
|
|
} |
|
|
|
|