Exemple #1
0
 public Game DeleteGame(int ID)
 {
     game = default(Game);
     try
     {
         game = gameRepo.Delete(ID);
         if (!(game is default(Game)))
         {
             List <ActivePlayer> lst = activePlayerRepo.FindAll().ToList();
             foreach (ActivePlayer a in lst)
             {
                 string[] str = a.ID.Split('.');
                 int      IDGame;
                 bool     ok = int.TryParse(str[1], out IDGame);
                 if (ok)
                 {
                     if (IDGame == ID)
                     {
                         activePlayerRepo.Delete(a.ID);
                     }
                 }
             }
         }
     }
     catch (ValidationException ex)
     {
         Console.WriteLine(ex.Message.ToString());
     }
     return(game);
 }
Exemple #2
0
 public Player DeletePlayer(int ID)
 {
     player = default(Player);
     try
     {
         player = playerRepo.Delete(ID);
         if (!(player is default(Player)))
         {
             List <ActivePlayer> lst = activePlayerRepo.FindAll().ToList();
             foreach (ActivePlayer a in lst)
             {
                 string[] str = a.ID.Split('.');
                 int      IDPlayer;
                 bool     ok = int.TryParse(str[0], out IDPlayer);
                 if (ok)
                 {
                     if (IDPlayer == ID)
                     {
                         activePlayerRepo.Delete(a.ID);
                     }
                 }
             }
         }
     }
     catch (ValidationException ex)
     {
         Console.WriteLine(ex.Message.ToString());
     }
     return(player);
 }
Exemple #3
0
        public List <Player> FindPlayersGameTeam(int teamId, int gameId)
        {
            Game game = gameRepository.FindOne(gameId);

            if (game == null)
            {
                throw new ValidationException("Inexistent game");
            }
            if (game.FirstTeamId != teamId && game.SecondTeamId != teamId)
            {
                throw new ValidationException("Team wasn't involved in the game");
            }
            return(repository.FindAll()
                   .Where(a => (a.Id.IdGame == gameId && playerRepository.FindOne(a.Id.IdPlayer).TeamId == teamId))
                   .Select(a => playerRepository.FindOne(a.Id.IdPlayer))
                   .ToList());
        }
Exemple #4
0
 public IEnumerable <ActivePlayer> GetAll()
 {
     return(activePlayerRepo.FindAll());
 }