Beispiel #1
0
        // POST: PlayerList/Edit/5
        public ActionResult EditPlayer(int id, string name, int keep, int midfield, int attack, int defend)
        {
            try
            {
                // TODO: Add update logic here
                using (PVMEntities1 db = new PVMEntities1())
                {
                    var player = db.Player.Where(x => x.ID == id).FirstOrDefault();
                    player.PlayerName = name;
                    player.Keep       = keep;
                    player.Midfield   = midfield;
                    player.Attack     = attack;
                    player.Defend     = defend;

                    db.Entry(player).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("PlayerListIndex"));
            }
            catch (Exception)
            {
                return(RedirectToAction("PlayerListIndex"));
            }
        }
Beispiel #2
0
 public ActionResult Edit(int id, [Bind(Include = "ID,PlayerName,Keep,Midfield,Attack,Defend")] Player player)
 {
     try
     {
         using (PVMEntities1 db = new PVMEntities1())
         {
             db.Entry(player).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("PlayerListIndex"));
     }
     catch (Exception)
     {
         return(View());
     }
 }