public IActionResult Create(CreateExamDTO Exam) { var a = RSSHelper.GetSubjects("https://www.wired.com/feed/rss"); int examID = _examService.Add(new Entity.Exam { Header = a.Where(x => x.Description == Exam.Description).FirstOrDefault().Title, MemberID = HttpContext.Session.GetObjectFromJson <Member>("Member").ID, Description = Exam.Description }); foreach (var item in Exam.Question) { int quesID = _questionOfExamService.Add( new QuestionOfExam { ExamID = examID, Question = item.Question } ); for (int i = 0; i < 4; i++) { _optionsOfQuestionService.Add(new OptionsOfQuestion { Option = item.Options[i].Option, QuestionOfExamID = quesID, IsCorrect = ((Convert.ToInt32(item.Answer) - 65) == i) ? true : false }); } foreach (var item2 in item.Options) { } } return(RedirectToAction("Index", "Member")); }
public IActionResult Create() { List <SubjectDTO> subjects = RSSHelper.GetSubjects("https://www.wired.com/feed/rss").ToList(); List <SelectListItem> subjectsSelect = new List <SelectListItem>(); foreach (var item in subjects.Take(5)) { subjectsSelect.Add(new SelectListItem { Text = item.Title, Value = item.Description }); } ViewBag.Subject = subjectsSelect; return(View()); }