public async Task <IActionResult> GenerateTestData()
        {
            await Task.Run(() =>
            {
                var pairs = CacheProvider.Pairs.Take(20000);

                for (int i = 0; i < 10; i++)
                {
                    IList <Question> questions = new List <Question>();
                    var clientId = new Random().Next(50);
                    foreach (var pair in pairs)
                    {
                        int numberOfWord = Convert.ToInt32(Math.Floor(new Random().NextDouble() * (3 - 1) + 1));


                        Models.Question question = new Question()
                        {
                            PairID             = pair.Id,
                            QuestionWordNumber = numberOfWord,
                            DateOfCreation     = DateTime.UtcNow,
                            UserClientID       = clientId,
                            Type         = 1,
                            DateOfAnswer = DateTime.UtcNow
                        };
                        questions.Add(question);
                    }
                    QuestionDatabaseProvider.AddRange(questions);
                }
            });

            return(await Task.FromResult(new OkResult()));
        }
        private async Task <Question> UpdateQuestionRepository(Question question, ApiModels.Answer answer)
        {
            question.Answer           = answer.AnswerText;
            question.DateOfAnswer     = DateTime.UtcNow;
            question.WasAnswerCorrect = true;

            var result = QuestionDatabaseProvider.Update(question);

            return(await Task.FromResult(result));
        }
        public Question AddNewQuestionWithUnbindPair(Pair unbindPair, int userClientId, int numberOfWord)
        {
            Models.Question question = new Question()
            {
                PairID             = unbindPair.Id,
                QuestionWordNumber = numberOfWord,
                DateOfCreation     = DateTime.UtcNow,
                UserClientID       = userClientId,
                Type = 1,
            };

            question = QuestionDatabaseProvider.Add(question);

            return(question);
        }
        private async Task <bool> RefreshCaches(bool ForceRefresh = false)
        {
            if (PairCache == null || ForceRefresh)
            {
                PairCache = PairDatabaseProvider.GetAll();
            }
            if (QuestionCache == null || ForceRefresh)
            {
                QuestionCache = QuestionDatabaseProvider.GetAll();
            }
            if (UserPairScoreCache == null || ForceRefresh)
            {
                UserPairScoreCache = UserPairScoreDatabaseProvider.GetAll();
            }


            return(await Task.FromResult(true));
        }