public async Task <PaginatedResult <TransactionBidVm> > Handle(GetAllTransactionBidQuery request, CancellationToken cancellationToken) { if (!(await _bidService.AnyByIdAsync(request.BidId))) { return(PaginatedResult <TransactionBidVm> .Empty(request.PageSize, request.PageNumber)); } return(await _dbContext.TransactionBids.AsQueryable() .Where(x => x.BidId == request.BidId) .OrderByDescending(x => x.Amount) .Select(x => new TransactionBidVm { Amount = x.Amount, Owner = _userService.GetUsername(new Guid(x.CreatedBy)) }) .ToPaginatedListAsync(request.PageNumber, request.PageSize)); }
public async Task <PaginatedResult <BidVm> > Handle(GetAllBidQuery request, CancellationToken cancellationToken) { if (!(await _productService.AnyByIdAsync(request.ProductId))) { return(PaginatedResult <BidVm> .Empty(request.PageSize, request.PageNumber)); } return(await _dbContext.Bids.AsQueryable() .OrderByDescending(x => x.CreatedDt) .Select(x => new BidVm { IsActive = x.IsActive, CreatedAt = x.CreatedDt.Value, ExpiredAt = x.ExpiredUtc, HighestAmount = x.HighestAmount, WinnerBy = _userService.GetUsername(new Guid(x.WinnerBy)) }) .ToPaginatedListAsync(request.PageNumber, request.PageSize)); }