Пример #1
0
        public ActionResult Add(MatchViewModels model)
        {
            if(ModelState.IsValid)
            {
                TempData["MatchAdded"] = "Added the match";
                // Add match to the database
                dbm.AddMatch(model);
                RedirectToAction("Table", "Statistics");
            }

            TempData["MatchAdded"] = "Error on adding the match.";

            ModelState.AddModelError("", "Niet alle gegevens zijn juist ingevuld.");
            return RedirectToAction("Table", "Statistics", model);
        }
Пример #2
0
        public void AddMatch(MatchViewModels model)
        {
            Match match = new Match
            {
                MatchedPlayed = DateTime.Parse(model.MatchDate),
                HomeTeamID = model.HomeTeamID,
                HomeTeamScored = model.HomeTeamScored,
                AwayTeamID = model.AwayTeamID,
                AwayTeamScored = model.AwayTeamScored
            };

            db.Matches.Add(match);
            db.SaveChanges();

            return;
        }