public ActionResult View(int Id) { MatchReportRepository db = new MatchReportRepository(); var report = db.GetAllMatchDetails().Where(k => k.MatchDetailsId == Id).FirstOrDefault(); return(View(report)); }
public ActionResult Statistic() { List <Scorrer> topscorrer = new List <Scorrer>(); MatchReportRepository mdetailsrep = new MatchReportRepository(); var matchdet = mdetailsrep.GetAllMatchDetails(); PlayerRepository playerrep = new PlayerRepository(); var allplayers = playerrep.GetAllPlayers(); foreach (Player p in allplayers) { Scorrer scorrer = new Scorrer(); scorrer.Id = p.ID; scorrer.Name = p.LastName; scorrer.TeamName = p.Team.Name; scorrer.FName = p.Name; scorrer.Picture = p.Picture; int goals = 0; var players = matchdet.Where(g => g.ID == p.ID); foreach (MatchDetails pl in players) { if (pl.StatisticId == 7) { goals++; } } scorrer.Goals = goals; topscorrer.Add(scorrer); ViewData["Scorrer"] = topscorrer.Where(g => g.Goals > 0).OrderByDescending(k => k.Goals); } return(View()); }
public ActionResult Add(MatchReport report) { List <SelectListItem> matcheslist = new List <SelectListItem>(); MatchesRepository matchesrep = new MatchesRepository(); var mymatches = matchesrep.GetAllMatches().OrderByDescending(k => k.Timestamp); if (mymatches.Count() > 0) { foreach (Match m in mymatches) { SelectListItem sli = new SelectListItem(); sli.Value = m.Id.ToString(); sli.Text = m.HomeTeamName + " (" + m.HomeGoals + " - " + m.AwayGoals + ") " + m.AwayTeamName; matcheslist.Add(sli); } } ViewData["Matches"] = matcheslist; if (!String.IsNullOrEmpty(report.Contents)) { MatchReportRepository matchreportrep = new MatchReportRepository(); matchreportrep.Add(report); matchreportrep.SaveChanges(); return(Redirect("/matchreports")); } else { ModelState.AddModelError("Contents", "Please make sure you've entered a match report"); } return(View(report)); }
// GET: MatchDetails public ActionResult Index() { MatchReportRepository db = new MatchReportRepository(); var matchdetails = db.GetAllMatchDetails(); ViewData["Reports"] = matchdetails; return(View()); }
// GET: Home public ActionResult Index() { MatchReportRepository matchreportrep = new MatchReportRepository(); var report = matchreportrep.GetAllReports().OrderByDescending(k => k.Match.Timestamp).FirstOrDefault(); return(View(report)); }
public ActionResult All() { MatchReportRepository matchreportsrep = new MatchReportRepository(); var mymatchreports = matchreportsrep.GetAllReports(); if (mymatchreports.Count() > 0) { ViewData["Reports"] = mymatchreports.OrderByDescending(k => k.Match.Timestamp).ThenByDescending(k => k.Id); } return(View()); }
public ActionResult View(int Id) { TeamsRepository teamsrep = new TeamsRepository(); var allteams = teamsrep.GetAllTeams().Where(k => k.Id != Id).OrderBy(k => k.TeamName); if (allteams.Count() > 0) { ViewData["AllTeams"] = allteams; } var team = teamsrep.GetAllTeams().Where(k => k.Id == Id).FirstOrDefault(); if (team != null) { MatchReportRepository matchreportrep = new MatchReportRepository(); var allreports = matchreportrep.GetAllReports().Where(k => k.Match.HomeTeamId == Id || k.Match.AwayTeamId == Id).OrderByDescending(k => k.Match.Timestamp); if (Request.QueryString["opponent"] != null) { var opponent = allteams.Where(k => k.Id.ToString() == Request.QueryString["opponent"].ToString()).FirstOrDefault(); if (opponent != null) { ViewData["OpponentTeamName"] = opponent.TeamName; allreports = allreports.Where(k => k.Match.HomeTeamId == opponent.Id || k.Match.AwayTeamId == opponent.Id).OrderByDescending(k => k.Match.Timestamp); } } var allhomegames = allreports.Where(k => k.Match.HomeTeamId == Id); var allawaygames = allreports.Where(k => k.Match.AwayTeamId == Id); if (allhomegames.Count() > 0) { ViewData["HomeGames"] = allhomegames; } if (allawaygames.Count() > 0) { ViewData["AwayGames"] = allawaygames; } return(View(team)); } else { return(Redirect("/")); } }
public ActionResult View(int Id) { MatchReportRepository matchreportrep = new MatchReportRepository(); var report = matchreportrep.GetAllReports().Where(k => k.Id == Id).FirstOrDefault(); if (report != null) { return(View(report)); } else { return(Redirect("/")); } }
public ActionResult PlayerStatistic(int Id) { List <Scorrer> topscorrer = new List <Scorrer>(); MatchReportRepository mdetailsrep = new MatchReportRepository(); var matchdet = mdetailsrep.GetAllMatchDetails(); PlayerRepository playerrep = new PlayerRepository(); var allplayers = playerrep.GetAllPlayers().Where(i => i.ID == Id); foreach (Player p in allplayers) { Scorrer scorrer = new Scorrer(); scorrer.Id = p.ID; scorrer.Name = p.LastName; scorrer.TeamName = p.Team.Name; scorrer.FName = p.Name; scorrer.Picture = p.Picture; int yellowCard = 0; int redCard = 0; int goals = 0; var players = matchdet.Where(g => g.ID == p.ID); // var statplayer = players.Where(i => i.ID == Id); foreach (MatchDetails pl in players) { if (pl.StatisticId == 7) { goals++; } if (pl.StatisticId == 8) { yellowCard++; } if (pl.StatisticId == 11) { redCard++; } } scorrer.Goals = goals; scorrer.YellowCard = yellowCard; scorrer.RedCard = redCard; topscorrer.Add(scorrer); ViewData["PlayerStat"] = topscorrer.OrderByDescending(k => k.Goals); } return(View()); }