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

            var pageOptionFilterModel = this.pageOptionFilterMapper.Map(pageOptionFilter);
            var pages = await this.pageRepository.GetAsync(pageOptionFilterModel, cancellationToken).ConfigureAwait(false);

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

            var pageViewModels = this.pageMapper.MapList(pages);

            return(new OkObjectResult(pageViewModels));
        }
Exemplo n.º 2
0
 public Task <IActionResult> GetAsync(
     [FromServices] GetPageCommand command,
     [FromQuery] PageOptionFilter pageOptionFilter,
     CancellationToken cancellationToken) => command.ExecuteAsync(pageOptionFilter, cancellationToken);