public List <TournoiContract> GetTournois() { List <TournoiContract> list = new List <TournoiContract>(); List <Tournoi> listtournoi = new List <Tournoi>(); List <MatchContract> listmatch = new List <MatchContract>(); listmatch = GetMatchs(); listtournoi = jtm.getAllTournois(); foreach (Tournoi t in listtournoi) { TournoiContract tournoi = new TournoiContract(); tournoi.Matchs = new List <MatchContract>(); //Tournoi tournoi2 = listtournoi.Find(x => x.Nom == t.Nom); foreach (Match m in t.Matchs /*tournoi2.Matchs*/) { MatchContract match = new MatchContract(); match = listmatch.Find(x => x.Id == m.ID); if (match != null) { tournoi.Matchs.Add(match); } } tournoi.Nom = t.Nom; tournoi.Id = t.ID; list.Add(tournoi); } return(list); }
public List<TournoiContract> GetTournois() { List<TournoiContract> list = new List<TournoiContract>(); List<Tournoi> listtournoi = new List<Tournoi>(); List<MatchContract> listmatch = new List<MatchContract>(); listmatch = GetMatchs(); listtournoi = jtm.getAllTournois(); foreach (Tournoi t in listtournoi) { TournoiContract tournoi = new TournoiContract(); tournoi.Matchs = new List<MatchContract>(); //Tournoi tournoi2 = listtournoi.Find(x => x.Nom == t.Nom); foreach(Match m in t.Matchs /*tournoi2.Matchs*/) { MatchContract match = new MatchContract(); match = listmatch.Find(x => x.Id == m.ID); if (match != null) { tournoi.Matchs.Add(match); } } tournoi.Nom = t.Nom; tournoi.Id = t.ID; list.Add(tournoi); } return list; }