示例#1
0
        public ActionResult Add(MatchReport report)
        {
            List <SelectListItem> matchesList = new List <SelectListItem>();
            MatchesRepository     matchesRep  = new MatchesRepository();
            var myMatches = matchesRep.GetAllMatches().OrderBy(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 (ModelState.IsValid)
                {
                    MatchReportsRepository matchreportrep = new MatchReportsRepository();

                    matchreportrep.Add(report);
                    matchreportrep.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(View(report));
        }
        public ActionResult Index()

        {
            MatchReportsRepository matchreportrep = new MatchReportsRepository();
            var report = matchreportrep.GetAllMatchReports().OrderByDescending(l => l.Match1.TimeStamp).FirstOrDefault();

            return(View(report));
        }
        public ActionResult View(int Id)
        {
            TeamsRepository teamssrep = new TeamsRepository();

            var allteams = teamssrep.GetAllTeams().Where(l => l.Id != Id).OrderBy(l => l.TeamName);


            if (allteams != null)
            {
                ViewData["Teams"] = allteams;
            }


            var team = teamssrep.GetAllTeams().Where(l => l.Id == Id).FirstOrDefault();

            if (team != null)


            {
                MatchReportsRepository matchesreportrep = new MatchReportsRepository();

                var allreports = matchesreportrep.GetAllMatchReports().Where(l => l.Match1.HomeTeamId == Id || l.Match1.AwayTeamId == Id).OrderByDescending(l => l.Match1.TimeStamp);

                if (Request.QueryString["Opponent"] != null)

                {
                    var opponent = allteams.Where(l => l.Id.ToString() == Request.QueryString["Opponent"].ToString()).FirstOrDefault();
                    ViewData["OpponentTeamName"] = opponent.TeamName;
                    allreports = allreports.Where(l => l.Match1.HomeTeamId == opponent.Id || l.Match1.AwayTeamId == opponent.Id).OrderByDescending(l => l.Match1.TimeStamp);
                }


                var allhomegames = allreports.Where(l => l.Match1.HomeTeamId == Id);
                var allawaygames = allreports.Where(l => l.Match1.AwayTeamId == Id);

                if (allhomegames.Count() > 0)
                {
                    ViewData["HomeGames"] = allhomegames;
                }
                if (allawaygames.Count() > 0)
                {
                    ViewData["AwayGames"] = allawaygames;
                }

                return(View(team));
            }

            else
            {
                return(Redirect("Index"));
            }
        }
示例#4
0
        public ActionResult View(int Id)
        {
            MatchReportsRepository matchesrep = new MatchReportsRepository();
            var report = matchesrep.GetAllMatchReports().Where(l => l.Id == Id).FirstOrDefault();

            if (report != null)
            {
                return(View(report));
            }

            else
            {
                return(Redirect("Index"));
            }
        }
示例#5
0
        public ActionResult All()

        {
            MatchReportsRepository matchreprep = new MatchReportsRepository();
            var myMatchReports = matchreprep.GetAllMatchReports();

            if (myMatchReports.Count() > 0)
            {
                ViewData["Reports"] = myMatchReports.OrderByDescending(k => k.Match1.TimeStamp).ThenByDescending(k => k.Id);
                //viewdata like a tag which contains all the information and put into view
            }



            return(View());
        }