public ActionResult GetSubjectsToPractice(int studyTaskId, int pageIndex) { StudentPracticeBll bll = new StudentPracticeBll(); int totalCount = 0; var result = bll.GetTaskSubject(studyTaskId, pageIndex, out totalCount); SubjectBll subjectBll = new SubjectBll(); var subjectIds = result.Select(s => s.SubjectId); var subjects = subjectBll.GetSubjectsByIds(subjectIds); foreach (var item in result) { //为vm的MainKnowledgeId属性赋值 var subject = subjects.FirstOrDefault(s => s.Ysj_Id == item.SubjectId); item.KnowledgeId = subject.Ysj_MainKnowledgeId; } return(Json( new AbhsTableJsonResponse(result, totalCount), JsonRequestBehavior.AllowGet)); }
public ActionResult GetGroupedSubjects(DtoQuestionSearch search) { var subjectGroup = new SubjectGroupBll().GetBySubjectId(search.Id); IList <SubjectViewModel> list = new List <SubjectViewModel>(); if (subjectGroup != null && !string.IsNullOrWhiteSpace(subjectGroup.Ysg_RelSubjectId)) { var ids = subjectGroup.Ysg_RelSubjectId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)); SubjectBll bll = new SubjectBll(); var subjects = bll.GetSubjectsByIds(ids); if (subjects != null && subjects.Count > 0) { list = subjects.Select(s => SubjectViewModel.Create(s)).ToList(); } } var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }