private void SetQuizList(int Id) { var QuizId = Repository.FindById(Id); Quizes = Quizes.Where(p => p.CatId == Id).ToList(); foreach (var item in Quizes) { QuizAnswers = RepositoryAnswers.GetAll().ToList(); var s = QuizAnswers.Where(p => p.Id == item.Id); QuizAnswersList.AddRange(s); } }
public void OnPost(int Id, string answer = "") { SetCatList(); Quizes = Repository.GetAll().ToList(); QuizAnswers = RepositoryAnswers.GetAll().ToList(); if (!string.IsNullOrEmpty(answer)) { var Answer = answer.Split(";"); CatSelectedId = GetCatList(int.Parse(Answer[1])); SetQuizList(CatSelectedId); if (string.IsNullOrEmpty(AnsweredQuestions)) { AnsweredQuestions = ""; } if (!AnsweredQuestions.Contains(Answer[0])) { foreach (var answerChosen in QuizAnswers) { if (answerChosen.CorrectAns == int.Parse(Answer[0])) { TempData["AnswerCount"] = AnswerCount++; break; } } AnsweredQuestions += Answer[0].ToString() + " "; } } else { if (Id == 1 || Id == 2) { SetQuizList(Id); } else { movieQuizList = Movies.GetAll(); } } }