public ActionResult Fixtures(Int32 id) { var dbAdapter = new SelectCommands(); var _fixtures = dbAdapter.GetHistoricFixByLeagueId(id); var teams = dbAdapter.GetAllTeams(); if (!_fixtures.Any()) return HttpNotFound(); var fixtures = new List<FixtureViewModels>(); var leagues = dbAdapter.GetAllLeagues(); foreach (var _fixture in _fixtures.Where(f=>f.H_SHOTS ==null)) { var tempFixture = new FixtureViewModels() { HomeTeam = teams.FirstOrDefault(team => team.API_TEAM_ID == Convert.ToInt32(_fixture.H_TEAM_ID))?.TEAM_NAME, AwayTeam = teams.FirstOrDefault(team => team.API_TEAM_ID == Convert.ToInt32(_fixture.A_TEAM_ID))?.TEAM_NAME, FixDate = _fixture.FIX_DATE.ToString() }; fixtures.Add(tempFixture); } return View("_Fixtures",fixtures); }
public ActionResult About() { //ViewBag.Message = "Your application description page."; var dbAdapter = new SelectCommands(); var _leagues = dbAdapter.GetAllLeagues(); var _fixtures = dbAdapter.GetHistoricFixByLeagueId(3); var teams = dbAdapter.GetAllTeams(); if (!_fixtures.Any()) return HttpNotFound(); var fixtures = _fixtures.Where(f => f.H_SHOTS == null).Select(fixture => new FixtureViewModels() { HomeTeam = teams.FirstOrDefault(team => team.API_TEAM_ID == Convert.ToInt32(fixture.H_TEAM_ID))?.TEAM_NAME, AwayTeam = teams.FirstOrDefault(team => team.API_TEAM_ID == Convert.ToInt32(fixture.A_TEAM_ID))?.TEAM_NAME, FixDate = fixture.FIX_DATE.ToString() }).ToList(); if (!_leagues.Any()) return HttpNotFound(); var leagues = new LeaguesModel() { //SelectedLeagueId = "3", Leagues = _leagues, Fixtures = fixtures }; return View(leagues); }