コード例 #1
0
        public IActionResult GetInAuctionItems(SearchCriteriaDTO searchDTO, InAuctionItemsOrderBy orderBy = InAuctionItemsOrderBy.Name)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

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

            return(Json(result));
        }
コード例 #2
0
        public PagedInAuctionItemsDTO GetInAuctionItems(InAuctionItemsOrderBy orderBy, SearchCriteriaDTO searchDTO)
        {
            var         c         = searchDTO;
            var         spec      = new ItemSpecyfication(Status.InAuction, searchDTO.UserId, searchDTO.Phrase);
            var         orderSpec = new OrderInAuctionItemSpecyfication(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 PagedInAuctionItemsDTO
            {
                TotalAmount = items.Count(),
                Items       = _mapper.Map <List <Item>, List <InAuctionItemDTO> >(list)
            };

            return(result);
        }
コード例 #3
0
        public OrderInAuctionItemSpecyfication(InAuctionItemsOrderBy orderBy)
        {
            _orderBy = orderBy;

            switch (_orderBy)
            {
            case InAuctionItemsOrderBy.BuyNowPrice:
            { _expression = (x => x.ConstPrice); break; }

            case InAuctionItemsOrderBy.Payment:
            { _expression = (x => x.Payment.Name); break; }

            case InAuctionItemsOrderBy.StartDate:
            { _expression = (x => x.Payment.Name); break; }

            case InAuctionItemsOrderBy.EndDate:
            { _expression = (x => x.Payment.Name); break; }

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