// // GET: /Team/Edit/5 public ActionResult Edit(int id = 0) { Team team = db.Teams.Find(id); if (team == null) { return HttpNotFound(); } EditCreateTeamViewModel model = new EditCreateTeamViewModel(team); return View(model); }
public ActionResult Edit(EditCreateTeamViewModel teamModel) { if (ModelState.IsValid) { Team team = new Team(teamModel); db.Entry(team).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(teamModel); }
public ActionResult Create(EditCreateTeamViewModel teamModel) { if (ModelState.IsValid) { Team team = new Team(teamModel); db.Teams.Add(team); db.SaveChanges(); return RedirectToAction("Index"); } return View(teamModel); }
public Team(EditCreateTeamViewModel teamModel) { base.Id = teamModel.Id; base.Name = teamModel.Name; this.DateCreated = DateTime.Now; }