public IActionResult Part4Create() { return(View($"{nameof(Part4)}/{nameof(Part4Create)}", new ReadingCombined { TestCategory = TestCategory.ReadingCategory(4), ReadingPartTwos = ReadingPartTwo.Generate(Config.MAX_READING_PART_4_QUESTION) })); }
public IActionResult Part4Update(long id) { if (id <= 0) { return(BadRequest()); } else { var testCategory = _TestCategoryManager.Get(id); if (testCategory == null) { return(NotFound()); } var readingPartTwos = _ReadingPartTwoManager.GetAll(testCategory.Id).ToList(); if (readingPartTwos.Count <= 0) { readingPartTwos = ReadingPartTwo.Generate(Config.MAX_READING_PART_4_QUESTION); } for (int i = 0; i < readingPartTwos.Count(); i++) { if (readingPartTwos[i].Answers != null && readingPartTwos[i].Answers.Length > 0) { try { readingPartTwos[i].AnswerList = JsonConvert.DeserializeObject <List <BaseAnswer> >(readingPartTwos[i].Answers); } catch (Exception) { } } } return(View($"{nameof(Part4)}/{nameof(Part4Update)}", new ReadingCombined { TestCategory = testCategory, ReadingPartTwos = readingPartTwos })); } }