Example #1
0
        public List <Resultats> ObtenirLesResultats(int idSondage)
        {
            List <Resto>     restaurants = ObtientTousLesRestaurants();
            List <Resultats> resultats   = new List <Resultats>();
            Sondage          sondage     = listeDessondages.First(s => s.Id == idSondage);

            foreach (IGrouping <int, Vote> grouping in sondage.Votes.GroupBy(v => v.Resto.Id))
            {
                int   idRestaurant  = grouping.Key;
                Resto resto         = restaurants.First(r => r.Id == idRestaurant);
                int   nombreDeVotes = grouping.Count();
                resultats.Add(new Resultats {
                    Nom = resto.Nom, Telephone = resto.Telephone, NombreDeVotes = nombreDeVotes
                });
            }
            return(resultats);
        }