예제 #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);
 }
예제 #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);
        }
예제 #3
0
파일: DtoTeam.cs 프로젝트: slashP/EuroApi
 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;
 }
예제 #4
0
 // PUT /api/EuroApi/5
 public void Put(int id, Team team)
 {
     var oldTeam = _repository.Find(id);
     oldTeam.Name = team.Name;
     _repository.Save();
 }
예제 #5
0
 // POST /api/EuroApi
 public HttpResponseMessage<Team> Post(Team team)
 {
     var added = _repository.Add(team);
     _repository.Save();
     return new HttpResponseMessage<Team>(added);
 }
예제 #6
0
 // DELETE /api/EuroApi/5
 public void Delete(Team team)
 {
     _repository.Remove(team);
     _repository.Save();
 }