Modified commands to use auth and current user
This commit is contained in:
@@ -6,7 +6,6 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
namespace AipsCore.Application.Models.Whiteboard.Command.CreateWhiteboard;
|
||||
|
||||
public record CreateWhiteboardCommand(
|
||||
string OwnerId,
|
||||
string Title,
|
||||
int MaxParticipants,
|
||||
WhiteboardJoinPolicy JoinPolicy)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Application.Abstract.UserContext;
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Models.Whiteboard.External;
|
||||
using AipsCore.Domain.Models.Whiteboard.ValueObjects;
|
||||
@@ -8,20 +9,24 @@ namespace AipsCore.Application.Models.Whiteboard.Command.CreateWhiteboard;
|
||||
public class CreateWhiteboardCommandHandler : ICommandHandler<CreateWhiteboardCommand, WhiteboardId>
|
||||
{
|
||||
private readonly IWhiteboardRepository _whiteboardRepository;
|
||||
private readonly IUserContext _userContext;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateWhiteboardCommandHandler(IWhiteboardRepository whiteboardRepository, IUnitOfWork unitOfWork)
|
||||
|
||||
public CreateWhiteboardCommandHandler(IWhiteboardRepository whiteboardRepository, IUserContext userContext, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_whiteboardRepository = whiteboardRepository;
|
||||
_userContext = userContext;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task<WhiteboardId> Handle(CreateWhiteboardCommand command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var whiteboardCode = await WhiteboardCode.GenerateUniqueAsync(_whiteboardRepository);
|
||||
|
||||
var ownerId = _userContext.GetCurrentUserId();
|
||||
|
||||
var whiteboard = Domain.Models.Whiteboard.Whiteboard.Create(
|
||||
command.OwnerId,
|
||||
ownerId.IdValue,
|
||||
whiteboardCode.CodeValue,
|
||||
command.Title,
|
||||
command.MaxParticipants,
|
||||
|
||||
Reference in New Issue
Block a user