// // GET: /Games/Create public ActionResult Create() { GamesModel model = new GamesModel(); //Create instance of VM model.EventsList = GetEventsList(); return View(model); }
public ActionResult Create(GamesModel model) { if (ModelState.IsValid) { var StartDate = Request["Date"]; Events evt = SelectAllEvents().First(e => e.Id.ToString() == model.SelectedEvent); var game = new Games { Date = model.Date, Opponent_1 = model.Opponent_1, Opponent_2 = model.Opponent_2, Events = evt }; db.GamesSet.AddObject(game); db.SaveChanges(); return RedirectToAction("Index"); } return View(model); }