Пример #1
0
        public ActionResult Create(Player player)
        {
            if (ModelState.IsValid)
            {
                Db.Players.Add(player);
                Db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PlayerTypeId = new SelectList(Db.PlayerTypes, "Id", "Name", player.PlayerTypeId);
            ViewBag.TeamId = new SelectList(Db.Teams, "Id", "Name", player.TeamId);
            ViewBag.CountryId = new SelectList(Db.Countries, "Id", "Name", player.CountryId);
            return View(player);
        }
Пример #2
0
 public ActionResult Edit(Player player)
 {
     if (ModelState.IsValid)
     {
         Db.Entry(player).State = EntityState.Modified;
         Db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PlayerTypeId = new SelectList(Db.PlayerTypes, "Id", "Name", player.PlayerTypeId);
     ViewBag.TeamId = new SelectList(Db.Teams, "Id", "Name", player.TeamId);
     ViewBag.CountryId = new SelectList(Db.Countries, "Id", "Name", player.CountryId);
     return View(player);
 }