// // GET: /Team/Delete/5 public ActionResult Delete(int id = 0) { Team team = db.Teams.Find(id); if (team == null) { return HttpNotFound(); } ListDeleteTeamViewModel teamModel = new ListDeleteTeamViewModel(team); return View(teamModel); }
public ActionResult DeleteConfirmed(int id) { Team team = db.Teams.Find(id); if (team.Employees.Count != 0) { ViewBag.ValidationMessage = "You can't delete a team with employees present!"; ListDeleteTeamViewModel teamModel = new ListDeleteTeamViewModel(team); return View(teamModel); } db.Teams.Remove(team); db.SaveChanges(); return RedirectToAction("Index"); }