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}" }); } }
public async Task <IActionResult> GetAllAuthors() { try { var result = await _operationAuthors.GetAllAuthorsAsync(); return(Ok(result)); } catch (NoAuthorFoundException exception) { return(Ok(exception)); } }