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); }
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); }
public GemModel ObtenirGems(int id) { var listeGems = new GemDonnees().ObtenirGems(); return(listeGems.Where(pr => id == pr.Id).FirstOrDefault()); }