Refactoring
This commit is contained in:
@@ -37,7 +37,7 @@ public class DeleteWhiteboardCommandHandler : ICommandHandler<DeleteWhiteboardCo
|
||||
throw new ValidationException(WhiteboardErrors.NotFound(whiteboardId));
|
||||
}
|
||||
|
||||
if (!whiteboard.IsOwnedBy(userId))
|
||||
if (!whiteboard.CanUserDelete(userId))
|
||||
{
|
||||
throw new ValidationException(WhiteboardErrors.OnlyOwnerCanDeleteWhiteboard(userId));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using AipsCore.Domain.Common.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Abstract;
|
||||
|
||||
public interface ISoftDeletableRepository<in TId> where TId : DomainId
|
||||
{
|
||||
Task SoftDeleteAsync(TId id, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -3,8 +3,8 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.Whiteboard.External;
|
||||
|
||||
public interface IWhiteboardRepository : IAbstractRepository<Whiteboard, WhiteboardId>
|
||||
public interface IWhiteboardRepository
|
||||
: IAbstractRepository<Whiteboard, WhiteboardId>, ISoftDeletableRepository<WhiteboardId>
|
||||
{
|
||||
Task<bool> WhiteboardCodeExists(WhiteboardCode whiteboardCode);
|
||||
Task SoftDeleteAsync(WhiteboardId id, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace AipsCore.Domain.Models.Whiteboard;
|
||||
|
||||
public partial class Whiteboard
|
||||
{
|
||||
public bool IsOwnedBy(UserId userId)
|
||||
public bool CanUserDelete(UserId userId)
|
||||
{
|
||||
return WhiteboardOwnerId.IdValue == userId.IdValue;
|
||||
}
|
||||
Reference in New Issue
Block a user