public async Task <Team> ToggleTeamPlayer(TeamToggleRequest req)
 {
     using (var db = new TtcDbContext())
     {
         var team     = db.Teams.Include(x => x.Players).Single(x => x.Id == req.TeamId);
         var exPlayer = team.Players.SingleOrDefault(x => x.PlayerId == req.PlayerId);
         if (exPlayer == null)
         {
             team.Players.Add(new TeamPlayerEntity
             {
                 PlayerId   = req.PlayerId,
                 TeamId     = req.TeamId,
                 PlayerType = (TeamPlayerType)Enum.Parse(typeof(TeamPlayerType), req.Role)
             });
         }
         else
         {
             db.Entry(exPlayer).State = EntityState.Deleted;
         }
         db.SaveChanges();
         return(await GetTeam(req.TeamId, false));
     }
 }
 public Team ToggleTeamPlayer(TeamToggleRequest req)
 {
     using (var db = new TtcDbContext())
     {
         var team = db.Teams.Include(x => x.Players).Single(x => x.Id == req.TeamId);
         var exPlayer = team.Players.SingleOrDefault(x => x.PlayerId == req.PlayerId);
         if (exPlayer == null)
         {
             team.Players.Add(new TeamPlayerEntity
             {
                 PlayerId = req.PlayerId,
                 TeamId = req.TeamId,
                 PlayerType = (TeamPlayerType)Enum.Parse(typeof(TeamPlayerType), req.Role)
             });
         }
         else
         {
             db.Entry(exPlayer).State = EntityState.Deleted;
         }
         db.SaveChanges();
         return GetTeam(req.TeamId, false);
     }
 }