예제 #1
0
        public IActionResult GetBoughtItems(SearchCriteriaDTO searchDTO, BoughtItemsOrderBy orderBy = BoughtItemsOrderBy.Name)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            searchDTO.UserId = userId;
            var result = _itemService.GetBoughtItems(orderBy, searchDTO);

            return(Json(result));
        }
예제 #2
0
        public PagedBoughtItemsDTO GetBoughtItems(BoughtItemsOrderBy orderBy, SearchCriteriaDTO searchDTO)
        {
            var c         = searchDTO;
            var spec      = new ItemSpecyfication(Status.Bought, searchDTO.UserId, searchDTO.Phrase);
            var orderSpec = new OrderBoughtItemSpecyfication(orderBy);

            var         items = _unitOfWork.ItemRepo.GetSortedItems(spec, orderSpec);
            List <Item> list  = items.Skip((c.PageIndex - 1) * c.AmountOfPages).Take(c.AmountOfPages).ToList();

            var result = new PagedBoughtItemsDTO
            {
                TotalAmount = items.Count(),
                Items       = _mapper.Map <List <Item>, List <BoughtItemDTO> >(list)
            };

            return(result);
        }
        public OrderBoughtItemSpecyfication(BoughtItemsOrderBy orderBy)
        {
            _orderBy = orderBy;

            switch (_orderBy)
            {
            case BoughtItemsOrderBy.Payment:
            { _expression = (x => x.Payment.Name); break; }

            case BoughtItemsOrderBy.BuyNowPrice:
            { _expression = (x => x.ConstPrice); break; }

            case BoughtItemsOrderBy.EndDate:
            { _expression = (x => x.AuctionEnd); break; }

            case BoughtItemsOrderBy.StartDate:
            { _expression = (x => x.AuctionStart); break; }

            default:
            { _expression = (x => x.Name); break; }
            }
        }