protected FilterPatemetersDto BuildParametersDto(int skipItems = 0, int pageSize = 2)
        {
            var filterParameters = new FilterPatemetersDto()
            {
                PageSize  = pageSize,
                SkipItems = skipItems
            };

            return(filterParameters);
        }
Exemplo n.º 2
0
        public IActionResult GetOverviewItems([FromQuery] FilterPatemetersDto dto)
        {
            var response = _itemsDataService.GetItemsOverviewPageModel(this.UserId, dto);

            if (!response.IsSuccess)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
Exemplo n.º 3
0
        private IQueryable <ItemOverviewDto> GetOverviewItemsQuery(string userId, FilterPatemetersDto dto)
        {
            var query = GetBaseQuery(userId);

            query = FilterBySearchWord(dto.SearchWord, query);

            query = FilterBySearchDate(dto.SearchDate, query);

            query = Sort(dto.OrderByColumn, dto.OrderByDirection, query);

            return(query);
        }
Exemplo n.º 4
0
        public Response <ItemsOverviewPageDto> GetItemsOverviewPageModel(string userId, FilterPatemetersDto dto)
        {
            try
            {
                userId.ThrowIfNullOrEmpty();
                dto.ThrowIfNull();

                var query = GetOverviewItemsQuery(userId, dto);

                var dtos = query
                           .Skip(dto.SkipItems.Value)
                           .Take(dto.PageSize.Value)
                           .ToList();

                var itemsCount = query.Count();

                var pageDto = new ItemsOverviewPageDto()
                {
                    OverviewItems   = dtos,
                    TotalItemsCount = itemsCount
                };

                var response = ResponseBuilder.Success(pageDto);
                return(response);
            }
            catch (Exception ex)
            {
                var errorMessage = _localizer["OverviewItemsError"];
                var response     = ResponseBuilder.Failure <ItemsOverviewPageDto>(errorMessage);
                return(response);
            }
        }