Ejemplo n.º 1
0
        public ActionResult Add(Report report)
        {
            List <SelectListItem> matchlist = new List <SelectListItem>();
            MatchesRepository     matchrep  = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches().OrderByDescending(k => k.Fixture.TimeStamp);

            if (mymatches.Count() > 0)
            {
                foreach (Match m in mymatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.Fixture.HomeTeamName + " (" + m.HomeTeamGoals + " - " + m.AwayTeamGoals + " ) " + m.Fixture.HomeTeamName;
                    matchlist.Add(sli);
                }
            }
            ViewData["MyReports"] = matchlist;

            if (!String.IsNullOrEmpty(report.Comment))
            {
                //Continue
                ReportsRepository ReportRep = new ReportsRepository();
                ReportRep.Add(report);
                ReportRep.SaveChanges();

                return(Redirect("/reports"));
            }
            else
            {
                ModelState.AddModelError("Comment,", "Please make sure you have entered a match report");
            }
            return(View(report));
        }