public ActionResult Question() { var date = DateTime.Now.ToShortDateString(); var userId = Convert.ToInt32(GeneralHelpers.GetUserId()); var quiz = _knowledgeTestService.GetAll().Where(x => (Convert.ToDateTime(x.KnowledgeDate.ToShortDateString()) == Convert.ToDateTime(date))).ToList(); var answer = _answerQueryableRepository.Table.Where(x => x.UserId == userId).ToList(); List <KnowledgeTest> quizList = new List <KnowledgeTest>(); if (answer.Count == 0) { return(View(quiz)); } foreach (var quizItem in quiz) { foreach (var answerItem in answer) { if (answer.Count != quiz.Count) { if (quizItem.KnowledgeTestId != answerItem.KnowledgeTestId) { quizList.Add(_knowledgeTestService.GetById(answerItem.KnowledgeTestId)); } } } } return(View(quizList)); }
public ActionResult Edit(int id) { var data = AutoMapperHelper.MapToSameViewModel <KnowledgeTest, KnowledgeTestViewModel>(_knowledgeTestService.GetById(id)); return(View(data.ToVM())); }