Пример #1
0
        public Team DeleteTeam(int ID)
        {
            team = default(Team);
            try
            {
                team = repo.Delete(ID);
                if (!(team is (default(Team))))
                {
                    List <Player> lst = playerRepo.FindAll().ToList();
                    foreach (Player p in lst)
                    {
                        if (p.team.ID == ID)
                        {
                            playerRepo.Delete(p.ID);
                        }
                    }

                    List <Game> lstGame = gameRepo.FindAll().ToList();
                    foreach (Game g in lstGame)
                    {
                        if (g.teamOne.ID == ID || g.teamTwo.ID == ID)
                        {
                            gameRepo.Delete(g.ID);
                        }
                    }
                }
            }
            catch (ValidationException e)
            {
                Console.WriteLine(e.Message.ToString());
            }
            return(team);
        }
Пример #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);
 }