mirror of https://github.com/abpframework/abp.git
10 changed files with 122 additions and 8 deletions
@ -0,0 +1,31 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Domain.Services; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.Domain.Volo.CmsKit.Contents |
||||
|
{ |
||||
|
public class ContentManager : DomainService, IContentManager |
||||
|
{ |
||||
|
protected IContentRepository ContentRepository { get; } |
||||
|
public ContentManager(IContentRepository contentRepository) |
||||
|
{ |
||||
|
ContentRepository = contentRepository; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public async Task<Content> InsertAsync(Content content, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
if (await ContentRepository.ExistAsync(content.EntityType, content.EntityId, content.TenantId, cancellationToken)) |
||||
|
{ |
||||
|
throw new ContentAlreadyExistException(content.EntityType, content.EntityId); |
||||
|
} |
||||
|
|
||||
|
return await ContentRepository.InsertAsync(content); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.Domain.Volo.CmsKit.Contents |
||||
|
{ |
||||
|
public interface IContentManager |
||||
|
{ |
||||
|
Task<Content> InsertAsync(Content content, CancellationToken cancellationToken = default); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
using System; |
||||
|
using Volo.Abp; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents |
||||
|
{ |
||||
|
[Serializable] |
||||
|
public class ContentAlreadyExistException : BusinessException |
||||
|
{ |
||||
|
public ContentAlreadyExistException([NotNull] string entityType, [NotNull] string entityId) |
||||
|
{ |
||||
|
Code = CmsKitErrorCodes.ContentAlreadyExist; |
||||
|
WithData(nameof(Content.EntityType), entityType); |
||||
|
WithData(nameof(Content.EntityId), entityId); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue