public ActionResult MarkTaskDetail(int taskId) { var model = new MarkTaskDetailModel(); model.TaskId = taskId; var booktask = _bookWorkTaskService.GetBookWorkTask(taskId); var taskItems = booktask.BookWorkTaskItems.ToList(); //任务包含的Item model.TaskRelatedChapter = taskItems.Select(d => d.BookChapter).ToList(); IList <BookChapter> bookChapterList = new List <BookChapter>(); //IList<BookChapter> relateAllChapters = new List<BookChapter>(); foreach (var titem in taskItems) { var itemchapter = titem.BookChapter; while (itemchapter.BookChapterParent != null) { //if (!relateAllChapters.Contains(itemchapter)) //{ // relateAllChapters.Add(itemchapter); //} itemchapter = itemchapter.BookChapterParent; } if (!bookChapterList.Contains(itemchapter)) { bookChapterList.Add(itemchapter); } } bookChapterList = bookChapterList.OrderBy(p => p.Id).ToList(); model.RelateChapters = bookChapterList; //model.RelateAllChapters = relateAllChapters; return(View(model)); }
public ActionResult Detail(int taskId) { var model = new MarkTaskDetailModel { Id = taskId }; var booktask = _bookWorkTaskService.GetBookWorkTask(taskId); var taskItems = booktask.BookWorkTaskItems.ToList(); //任务包含的Item model.TaskRelatedChapter = taskItems.Select(d => d.BookChapter).ToList(); foreach (var titem in taskItems) { var itemchapter = titem.BookChapter; while (itemchapter.BookChapterParent != null) { itemchapter = itemchapter.BookChapterParent; } if (!model.RelateChapters.Contains(itemchapter)) { model.RelateChapters.Add(itemchapter); } } return(View(model)); }