Example #1
0
        public IActionResult OnPostAnswerAsync()
        {
            Questions = JsonSerializer.Deserialize <List <TagalogListItem> >(
                Encoding.UTF8.GetString(Convert.FromBase64String(SessionData)));

            if (QuestionAnswer?.Equals((DifficultyLevel == DifficultyLevel.Easy
                    ? Questions.First().English
                    : Questions.First().Tagalog), StringComparison.CurrentCultureIgnoreCase) ?? false)
            {
                AnswerResponse = "Great job, you are rocking this.";
                Questions.RemoveAt(0);
            }
            else
            {
                AnswerResponse = $"Oops, {Questions.First().Tagalog}: {Questions.First().English} - That's going to cost ya big time.";
                Questions.Add(Questions.First());
                Questions = Questions.OrderBy(x => Guid.NewGuid()).ToList();
            }

            ModelState.Clear();
            Init();
            SessionData    = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(Questions)));
            QuestionAnswer = "";
            return(Page());
        }