public async Task <IActionResult> GetItemById(int id)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            var item = await _storeViynlRepository.Find(ci => ci.Id == id);

            if (item.Any())
            {
                return(Ok(_autoMapper.Map <IEnumerable <StoreVinylDetailResponseModel> >(item)));
            }

            return(NotFound());
        }
Beispiel #2
0
        public async Task <IActionResult> GetByReferencesId(int?genreId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
        {
            if (!genreId.HasValue)
            {
                return(NotFound());
            }

            var results = await _storeViynlRepository.Find(_ => _.GenreId == genreId);

            var totalItems = results
                             .LongCount();

            var itemsOnPage = results.AsEnumerable()
                              .Paginate(pageIndex, pageSize);

            var model = new PaginationResponseModel <StoreVinylListResponseModel>(
                pageIndex, pageSize, totalItems, _autoMapper.Map <IEnumerable <StoreVinylListResponseModel> >(itemsOnPage));

            return(Ok(model));
        }