public EventGame GetEarnedPrices(int idProfil, int idEvent) { EventGame result = new EventGame(); using (MasterDBDataContext db = new MasterDBDataContext()) { GroupSign groupSign = db.GroupSign.SingleOrDefault(gs => gs.idProfil == idProfil && gs.idEvent == idEvent); if (groupSign != null) { int[] classement = new int[2]; classement = GetRankGroupSign(idEvent, idProfil); int classementPourcent = 100; if (classement[1] > 0) classementPourcent = classement[0] / classement[1] * 100; var earnedPricePool = db.PricePool.Where(pp => pp.idEvent == idEvent && ((classement[0] <= pp.placeRangeMin && classement[0] >= pp.placeRangeMax) || (classement[0] >= pp.placeRangeMin && classement[0] <= pp.placeRangeMax) || (classementPourcent <= pp.placePurcent))); if (earnedPricePool != null) { PricePool[] arrayEarnedPricePool = new PricePool[earnedPricePool.ToArray().Count()]; arrayEarnedPricePool = earnedPricePool.ToArray(); result.priceS = new PriceS[arrayEarnedPricePool.Count()]; for (int i = 0; i < arrayEarnedPricePool.Count(); i++) { result.priceS[i] = GetPrice((int)arrayEarnedPricePool[i].idPrice); } result.eventS = GetEvent(idEvent); return result; } } } //return -1; return null; }