public async Task <PagingQueryResult <CategoryPagingQueryDTO> > Handle(CategoryPagingQuery request, CancellationToken cancellationToken)
        {
            var result = new PagingQueryResult <CategoryPagingQueryDTO>();

            request.CheckPagingParam();

            var specification = new CategoryPagingSpecification(request.Page, request.PageSize, request.Search);
            var data          = await categoryRepository.Paging(specification).ToListAsync();

            result.Total = await categoryRepository.Get(specification).CountAsync();

            result.Data = data.Select(x => mapper.Map <CategoryPagingQueryDTO>(x)).ToList();

            return(result);
        }
Esempio n. 2
0
        public async Task <ActionResult <PagedData <CategoryPagingDTO> > > Gets([FromQuery] CategoryPagingQuery query)
        {
            if (query.Page <= 0)
            {
                return(this.BadRequest());
            }

            var data = await this._mediator.Send(query);

            var result = new ApiResult <PagedData <CategoryPagingDTO> >()
            {
                Message = ApiMessage.GetOk,
                Data    = data
            };

            return(this.Ok(result));
        }
Esempio n. 3
0
        public async Task <IActionResult> Get([FromQuery] CategoryPagingQuery query)
        {
            var list = await _mediator.Send(query);

            return(Ok(list));
        }