public ActionResult Edit(Team team) { if (ModelState.IsValid) { db.Entry(team).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.GroupId = new SelectList(db.Groups, "Id", "Name", team.GroupId); return View(team); }
public ActionResult Create(Team team) { if (ModelState.IsValid) { db.Teams.Add(team); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.GroupId = new SelectList(db.Groups, "Id", "Name", team.GroupId); return View(team); }
public static DtoTeam TeamToDto(Team team) { var dto = new DtoTeam { Name = team.Name, GroupName = team.Group.Name, Matches = DtoMatch.MatchesToDto(team.Matches), PlayedMatches = DtoMatch.MatchesToDto(team.PlayedMatches), Points = team.Points, GoalsConceded = team.GoalsConceded, GoalsScored = team.GoalsScored, GoalDifference = team.GoalDifference, Group = team.Group.Name }; dto.MatchCount = team.Matches.Count(x => x.HomeTeamGoals != null); return dto; }
// PUT /api/EuroApi/5 public void Put(int id, Team team) { var oldTeam = _repository.Find(id); oldTeam.Name = team.Name; _repository.Save(); }
// POST /api/EuroApi public HttpResponseMessage<Team> Post(Team team) { var added = _repository.Add(team); _repository.Save(); return new HttpResponseMessage<Team>(added); }
// DELETE /api/EuroApi/5 public void Delete(Team team) { _repository.Remove(team); _repository.Save(); }