public ActionResult GetMatchesData(string page) { var matches = _demoRepository.GetMatches() .Where(x => x.TotalSquadAScore + x.TotalSquadBScore > Settings.RoundsLimit) .ToList(); if (!matches.Any()) { return(Json("An error occurred getting matches")); } var pageNum = ParsePageNumber(page); var model = new MatchesViewModel { Matches = matches .OrderByDescending(x => x.MatchDate) .ThenByDescending(x => x.ParsedDate) .Skip((pageNum - 1) * Settings.MatchesLimit) .Take(Settings.MatchesLimit) .Select(x => new BaseMatch { Id = x.Id, Map = x.Map, Date = x.MatchDate, AScore = x.TotalSquadAScore, BScore = x.TotalSquadBScore, MapImage = GetMapImage(x.Map), Duration = x.Duration }), Pagination = new Pagination { PageSize = Settings.MatchesLimit, TotalPages = (int)Math.Ceiling((decimal)matches.Count() / Settings.MatchesLimit), CurrentPage = pageNum, TotalItems = matches.Count } }; return(Json(model)); }