public SportListModel GetSportListModel() { IEnumerable <SportInfo> sports = GetAllSports(); IEnumerable <TeamInfo> teams = GetAllTeams(); IEnumerable <PlayerInfo> players = GetAllPlayers(); SportListModel model = new SportListModel(); model.SportsList = sports.Select(x => new SportModel() { SportName = x.SportName, NumberOfTeams = teams == null ? 0 : teams.Where(y => y.TeamSport.SportName == x.SportName).Count(), NumberOfPlayers = players == null ? 0 : players.Where(y => teams.Any(z => z.TeamName == y.PlayerTeam.TeamName && z.TeamSport.SportName == x.SportName)).Count() }); return(model); }
public ActionResult GetAllSports() { SportListModel model = sportHelper.GetSportListModel(); return(Json(model, JsonRequestBehavior.AllowGet)); }