Exemple #1
0
        public async Task Consume(ConsumeContext <AuthorsRequestDto> context)
        {
            try
            {
                var result = await _operationAuthors.GetAllAuthorsAsync();

                var authors = _mapper.Map <IEnumerable <AuthorDto> >(result);
                await context.RespondAsync(new AuthorsResponseDto
                {
                    AuthorsDto = authors
                });
            }
            catch (NoAuthorFoundException e)
            {
                await context.RespondAsync(new NoAuthorFound
                {
                    CodeException    = e.CodeException,
                    MassageException = $"{e.Message}"
                });
            }
            catch (Exception e)
            {
                await context.RespondAsync(new NoAuthorFound
                {
                    MassageException = $"{e.Message}"
                });
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetAllAuthors()
        {
            try
            {
                var result = await _operationAuthors.GetAllAuthorsAsync();

                return(Ok(result));
            }
            catch (NoAuthorFoundException exception)
            {
                return(Ok(exception));
            }
        }