Beispiel #1
0
 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);
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 // PUT /api/EuroApi/5
 public void Put(int id, Team team)
 {
     var oldTeam = _repository.Find(id);
     oldTeam.Name = team.Name;
     _repository.Save();
 }
Beispiel #5
0
 // POST /api/EuroApi
 public HttpResponseMessage<Team> Post(Team team)
 {
     var added = _repository.Add(team);
     _repository.Save();
     return new HttpResponseMessage<Team>(added);
 }
Beispiel #6
0
 // DELETE /api/EuroApi/5
 public void Delete(Team team)
 {
     _repository.Remove(team);
     _repository.Save();
 }