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); }
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); }