Beispiel #1
0
        public async Task <IActionResult> GetList([FromQuery] DogsQueryFilter model)
        {
            var dogs = await dogService.GetList(model);

            var apiResponse = new ApiResponse <List <Dog> >(
                dogs,
                new PaginationMetadata()
            {
                CurrentPage        = dogs.CurrentPage,
                PageSize           = dogs.PageSize,
                TotalCount         = dogs.TotalCount,
                TotalPages         = dogs.TotalPages,
                HasNextPage        = dogs.HasNextPage,
                HasPreviousPage    = dogs.HasPreviousPage,
                NextPageNumber     = dogs.NextPageNumber,
                PreviousPageNumber = dogs.PreviousPageNumber
            }
                );

            return(Ok(apiResponse));
        }
        public async Task<IActionResult> GetAll([FromQuery] DogListQueryFilter model)
        {
            var response = await dogService.GetList(model);

            var apiResponse = new ApiResponse<List<DogDto>>(
                response.IsDone,
                response.Message,
                mapper.Map<List<Dog>, List<DogDto>>(response.Data),
                new PaginationMetadata()
                {
                    CurrentPage = response.Data.CurrentPage,
                    PageSize = response.Data.PageSize,
                    TotalCount = response.Data.TotalCount,
                    TotalPages = response.Data.TotalPages,
                    HasNextPage = response.Data.HasNextPage,
                    HasPreviousPage = response.Data.HasPreviousPage,
                    NextPageNumber = response.Data.NextPageNumber,
                    PreviousPageNumber = response.Data.PreviousPageNumber
                }
            );

            return Ok(apiResponse);
        }