diff --git a/FichaBackend/Services/IPublicDataService.cs b/FichaBackend/Services/IPublicDataService.cs index 6707035..62469d0 100644 --- a/FichaBackend/Services/IPublicDataService.cs +++ b/FichaBackend/Services/IPublicDataService.cs @@ -56,7 +56,9 @@ public class PublicDataService : IPublicDataService public async Task> GetAllCards() { - return await _databaseContext.CardQuestions.ToListAsync(); + var r = await _databaseContext.CardQuestions.ToListAsync(); + Utils.Extensions.Shuffle(r); + return r; } public async Task UpdateFilmsInCity(IEnumerable films) diff --git a/FichaBackend/Utils/Extensions.cs b/FichaBackend/Utils/Extensions.cs new file mode 100644 index 0000000..de8b990 --- /dev/null +++ b/FichaBackend/Utils/Extensions.cs @@ -0,0 +1,14 @@ +namespace FichaBackend.Utils; + +public static class Extensions +{ + private static readonly Random Rand = new Random(); + + public static void Shuffle(this IList values) + { + for (int i = values.Count - 1; i > 0; i--) { + int k = Rand.Next(i + 1); + (values[k], values[i]) = (values[i], values[k]); + } + } +} \ No newline at end of file