public async Task <dynamic> GetUserScheduledBetsPaginated(User user, int page) { var betsByUser = await _betDao.FindBetsByUser(user, 1); foreach (var bet in betsByUser) { var matchInformation = await _matchDao.FindMatch(bet.Match.Id); bet.Match = matchInformation; var awayTeamInformation = await _teamDao.FindTeam(bet.Match.AwayTeam.Id); if (awayTeamInformation != null) { bet.Match.AwayTeam = awayTeamInformation; } var homeTeamInformation = await _teamDao.FindTeam(bet.Match.HomeTeam.Id); if (homeTeamInformation != null) { bet.Match.HomeTeam = homeTeamInformation; } } var finishedBets = betsByUser.FindAll(bet => bet.Match.Status == Match.ScheduledStatus); var totalBets = finishedBets.Count(); var totalPages = totalBets / 10 + 1; page = page - 1; var betsToPass = 10 * page; var betsPaginated = await _betDao.PaginatedScheduledBets(betsToPass, user); dynamic obj = new ExpandoObject(); obj.Items = betsPaginated; obj.TotalPages = totalPages; obj.TotalBets = totalBets; obj.Page = page + 1; return(obj); }
public void AssertThatPaginatedScheduledBetsIsCalled() { _betDao.PaginatedScheduledBets(10, _user); _filterExpression = new ExpressionFilterDefinition <Bet>(b => b.Match.Id == _match.Id); _collection.Received().Find(_filterExpression); }