public ActionResult Create(Player player)
        {
            if (ModelState.IsValid)
            {
                db.PlayerSet.AddObject(player);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(player);
        }
 public ActionResult Edit(Player player)
 {
     if (ModelState.IsValid)
     {
         db.PlayerSet.Attach(player);
         db.ObjectStateManager.ChangeObjectState(player, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(player);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new Player object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="isAdmin">Initial value of the IsAdmin property.</param>
 public static Player CreatePlayer(global::System.Int32 id, global::System.String name, global::System.String userName, global::System.Boolean isAdmin)
 {
     Player player = new Player();
     player.Id = id;
     player.Name = name;
     player.UserName = userName;
     player.IsAdmin = isAdmin;
     return player;
 }
Esempio n. 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PlayerSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPlayerSet(Player player)
 {
     base.AddObject("PlayerSet", player);
 }