Hey I created a database with question. every question has a unique id (.ID) and a random generator randomly picks numbers and the the question with this number (id) is chosen and appears on the website.
So far so good but I want every question to appear a single time. Sadly every user request is unique so the values aren't remembered.
Is there an easy way to implement this to my code that my when form is transmitted my website still recognise the previous.
var questions = from m in _context.Question
select m;
var rowsTaken = new HashSet<int>();
Random r = new Random();
int rndRowIndex = r.Next(1, 10);
if (!string.IsNullOrEmpty(QuestionLayer))
{
do
{
questions = questions.Where(x => x.ID == rndRowIndex);
//questions = questions.Where(x => x.Layer == QuestionLayer);
} while (listids.Contains(rndRowIndex));
listids.Add(rndRowIndex);
}
Aucun commentaire:
Enregistrer un commentaire