Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public IEnumerable <Game> GetAll()
 {
     return(gameRepo.FindAll());
 }