public async Task <bool> Handle(DeleteChapterCommand request, CancellationToken cancellationToken)
        {
            var chapterSpecification = new ChapterByIdSpecification(request.ChapterId);

            if (!await _chapterRepository.AnyAsync(chapterSpecification))
            {
                _logger.LogError($"Chapter with id {request.ChapterId} not found");
                throw new InvalidOperationException($"Chapter with id {request.ChapterId} not found");
            }

            if (!await _chapterRepository.DeleteAsync(chapterSpecification))
            {
                _logger.LogError($"Delete chapter failed");
                throw new InvalidOperationException($"Delete chapter failed");
            }

            var message = _mapper.Map <DeleteChapterMessage>(request);
            await _sendEndpointProvider.Send(message, cancellationToken);

            return(true);
        }
        public async Task <Chapter> Handle(GetChapterByIdQuery request, CancellationToken cancellationToken)
        {
            var chapterSpecification = new ChapterByIdSpecification(request.ChapterId);

            return(await _chapterRepository.GetAsync(chapterSpecification));
        }