Exemple #1
0
        public List <GemModel> ObtenirGems(int numberRandom, int versionId)
        {
            List <GemModel> listModelRandom = new List <GemModel>();

            var random           = new Random();
            var listeGems        = new GemDonnees().ObtenirGems();
            var listeGemsVersion = listeGems
                                   .Where(pr => versionId == pr.VersionId).ToList();

            foreach (var gemModel in listeGemsVersion)
            {
                int index = random.Next(listeGemsVersion.Count);

                if (!listModelRandom.Contains(listeGemsVersion[index]))
                {
                    listModelRandom.Add(listeGemsVersion[index]);
                }
                if (listModelRandom.Count == numberRandom)
                {
                    break;
                }
            }

            return(listModelRandom);
        }
Exemple #2
0
        public List <GemModel> ObtenirGemsTous(int versionId)
        {
            List <GemModel> listModelRandom  = new List <GemModel>();
            var             listeGems        = new GemDonnees().ObtenirGems();
            var             listeGemsVersion = listeGems
                                               .Where(pr => versionId == pr.VersionId).ToList();

            return(listeGemsVersion);
        }
Exemple #3
0
        public GemModel ObtenirGems(int id)
        {
            var listeGems = new GemDonnees().ObtenirGems();

            return(listeGems.Where(pr => id == pr.Id).FirstOrDefault());
        }