public ActionResult DeleteConfirmed(int id) { Player player = db.Players.Find(id); Retired_Players rp = new Retired_Players(); rp.First_Name = player.First_Name; rp.Last_Name = player.Last_Name; rp.Goals = player.Goals; rp.Number = player.Number; rp.Position = player.Position; //now we have to go through the teams table to access the team name and team city Team team = db.Teams.Find(player.Team_Id); rp.City = team.City; rp.Team_Name = team.Name; db.Retired_Players.Add(rp); db.Players.Remove(player); db.SaveChanges(); return(RedirectToAction("Index", "Retired_Players")); }
public ActionResult DeleteConfirmed(int id) { Retired_Players retired_Players = db.Retired_Players.Find(id); db.Retired_Players.Remove(retired_Players); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,First_Name,Last_Name,Position,Number,Goals,Assists,City,Team_Name")] Retired_Players retired_Players) { if (ModelState.IsValid) { db.Entry(retired_Players).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(retired_Players)); }
public ActionResult Create([Bind(Include = "Id,First_Name,Last_Name,Position,Number,Goals,Assists,City,Team_Name")] Retired_Players retired_Players) { if (ModelState.IsValid) { db.Retired_Players.Add(retired_Players); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(retired_Players)); }
// GET: Retired_Players/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Retired_Players retired_Players = db.Retired_Players.Find(id); if (retired_Players == null) { return(HttpNotFound()); } return(View(retired_Players)); }