Beispiel #1
0
    public async Task <Unit> Handle(DeleteSpaceCommand request, CancellationToken cancellationToken)
    {
        var space = await _aggregateRepository.LoadAsync <Space>(request.SpaceId);

        await _resourceAuthorizationService.CheckAsync(space, CommonOperations.Delete);

        space.Delete();

        await _aggregateRepository.SaveAsync(space);

        return(Unit.Value);
    }
    public async Task <Unit> Handle(EditCommentCommand request, CancellationToken cancellationToken)
    {
        var comment = await _aggregateRepository.LoadAsync <Comment>(request.CommentId);

        await _resourceAuthorizationService.CheckAsync(comment, CommonOperations.Update);

        comment.Edit(request.Text);

        await _aggregateRepository.SaveAsync(comment);

        return(Unit.Value);
    }
    public async Task <Unit> Handle(UpdateSpaceCommand request, CancellationToken cancellationToken)
    {
        var space = await _aggregateRepository.LoadAsync <Space>(request.SpaceId);

        await _resourceAuthorizationService.CheckAsync(space, CommonOperations.Update);

        space.Update(
            _spaceValidatorService,
            request.Name,
            request.BackgroundImage,
            request.Visibility);

        await _aggregateRepository.SaveAsync(space);

        return(Unit.Value);
    }