public ActionResult Edit() { TeamsService teamsService = new TeamsService(); TeamsEditVM model = new TeamsEditVM(); TryUpdateModel(model); if (!ModelState.IsValid) { return View(model); } Team team; if (model.ID == 0) { team = new Team(); } else { team = teamsService.GetByID(model.ID); if (team == null) { return RedirectToAction("List"); } } team.ID = model.ID; team.Name = model.Name; teamsService.Save(team); return RedirectToAction("List"); }