public ActionResult DeletePerformer(long id) { if (!db.Teams.Any(x => x.Id == id)) { return(HttpNotFound()); } var model = new DeletePerformerTeamViewModel(); return(View(model)); }
public ActionResult DeletePerformer(long id, DeletePerformerTeamViewModel model) { var team = db.Teams.Find(id); if (model == null || team == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (!ModelState.IsValid) { return(RedirectToAction("Edit", new { id })); } var performer = team.Performers.SingleOrDefault(x => x.Id == model.PerformerId); if (performer != null) { team.Performers.Remove(performer); db.SaveChanges(); } return(RedirectToAction("Edit", new { id })); }