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); }
public ActionResult Edit(Games games) { if (ModelState.IsValid) { db.GamesSet.Attach(games); db.ObjectStateManager.ChangeObjectState(games, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(games); }
/// <summary> /// Deprecated Method for adding a new object to the GamesSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGamesSet(Games games) { base.AddObject("GamesSet", games); }
/// <summary> /// Create a new Games object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="opponent_1">Initial value of the Opponent_1 property.</param> /// <param name="opponent_2">Initial value of the Opponent_2 property.</param> /// <param name="date">Initial value of the Date property.</param> public static Games CreateGames(global::System.Int32 id, global::System.String opponent_1, global::System.String opponent_2, global::System.DateTime date) { Games games = new Games(); games.Id = id; games.Opponent_1 = opponent_1; games.Opponent_2 = opponent_2; games.Date = date; return games; }