public async Task <IActionResult> GetPastBetsByUser(int userId, [FromQuery] BetParams betParams) { var bets = await betRepository.GetPastBetsByUser(userId, betParams); Response.AddPagination(bets.CurrentPage, bets.PageSize, bets.TotalCount, bets.TotalPages); return(Ok(bets)); }
public async Task <PagedList <Bet> > GetPastBetsByUser(int userId, BetParams betParams) { var bets = dataContext.Bets.Include(b => b.Match).Include(b => b.Match.TeamA).Include(b => b.Match.TeamB).Where(b => b.UserId == userId && b.Match.Date < DateTime.Now).OrderByDescending(b => b.Id); return(await PagedList <Bet> .CreateAsync(bets, betParams.PageNumber, betParams.PageSize)); }