Esempio n. 1
0
        /// <summary>
        /// Execute async.
        /// </summary>
        /// <param name="bookOptionFilter">The book option filter.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>An action result.</returns>
        public async Task <IActionResult> ExecuteAsync(BookOptionFilter bookOptionFilter, CancellationToken cancellationToken)
        {
            if (bookOptionFilter is null)
            {
                throw new ArgumentNullException(nameof(bookOptionFilter));
            }

            var bookOptionFilterModel = this.bookOptionFilterMapper.Map(bookOptionFilter);
            var books = await this.bookRepository.GetAsync(bookOptionFilterModel, cancellationToken).ConfigureAwait(false);

            if (books is null || !books.Any())
            {
                return(new NotFoundResult());
            }

            var bookViewModels = this.bookMapper.MapList(books);

            return(new OkObjectResult(bookViewModels));
        }
Esempio n. 2
0
 public Task <IActionResult> GetAsync(
     [FromServices] GetBookCommand command,
     [FromQuery] BookOptionFilter bookOptionFilter,
     CancellationToken cancellationToken) => command.ExecuteAsync(bookOptionFilter, cancellationToken);