Beispiel #1
0
        public async Task <ActionResult <ChapterModel> > GetChapter(
            [FromRoute] ChapterReference reference,
            CancellationToken cancellationToken)
        {
            var query = new GetChapterQuery(reference.SagaId, reference.ChapterId);

            try
            {
                var response = await _sender.Send(query, cancellationToken);

                return(Ok(_mapper.Map <ChapterModel>(response)));
            }
            catch (ChapterNotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }
Beispiel #2
0
        public async Task <ActionResult> DeleteChapter(
            [FromRoute] ChapterReference reference,
            CancellationToken cancellationToken)
        {
            var command = new DeleteChapterCommand(reference.SagaId, reference.ChapterId);

            try
            {
                await _sender.Send(command, cancellationToken);
            }
            catch (ChapterNotFoundException e)
            {
                return(NotFound(e.Message));
            }

            return(NoContent());
        }