vendredi 5 mai 2017

random records display some specific records always first in list c#

There i created an application which have some records and shuffle it randomly. Actual scenario is that there are 100 records and in this 100 records i have 15 records which priority is first and when shuffling records this 15 records are always display first and then display other 85 records randomly. And in shuffling i divide those records into 6 means there are two rows in first rows have 3 records and second row have 3 records total 6 records display in one time then then shuffle display other 6 events into 100. All the records i added in cache with 30 mints. My code is below.

var r = new Random();
var shuffle = cachedRecords.OrderBy(x => r.Next(0, cachedRecords.Count())).ToList();
cachedRecords = (List<Records>)shuffle;
Cache.Set("key", cachedRecords, 1);

And for divide in 6 records per page

int maxPage = (int)(records.Count() / 6);
 if ((maxPage * 1.00) < Math.Round(records.Count() / 6.00, 2))
          maxPage = (int)Math.Round(maxPage * 1.00, 2) + 1; 




Aucun commentaire:

Enregistrer un commentaire