private void GetTRCount(CourseChapter chapter, QuestionsDbModel temp) { var t = ExtLinq.True <ChapterQuestionTR>(); t = t.And(x => (x.DeleteMark == null ? false : x.DeleteMark) != true); t = t.And(x => x.ChapterID == chapter.ID); var trList = questionTRService.IQueryable(t); if (trList != null) { temp.TRs = trList.Count(); } }
private void GetSelcetCount(CourseChapter chapter, QuestionsDbModel temp) { var s = ExtLinq.True <ChapterQuestionSelect>(); s = s.And(x => (x.DeleteMark == null ? false : x.DeleteMark) != true); s = s.And(x => x.ChapterID == chapter.ID); var selectList = questionSelectService.IQueryable(s); if (selectList != null) { temp.Selects = selectList.Count(); } }
public List <QuestionsDbModel> GetQuestionsDbList(Pagination pagination, string keyword) { var chapterList = GetChapterList(pagination, keyword); List <QuestionsDbModel> qDbList = new List <QuestionsDbModel>(); var top = chapterList.Where(x => x.PID == "0").ToList(); if (top.Count() >= 1) { //only two level ,filter third level List <CourseChapter> tempChapter = new List <CourseChapter>(); foreach (var item in top) { var temp = chapterList.Where(x => x.PID == item.ID).ToList(); temp.Add(item); tempChapter.AddRange(temp); } chapterList = tempChapter; foreach (var chapter in chapterList) { QuestionsDbModel temp = new QuestionsDbModel(); temp.ID = chapter.ID; temp.ChapterName = chapter.ChapterName; temp.CreatorTime = chapter.CreatorTime; temp.PID = chapter.PID; GetSelcetCount(chapter, temp); GetTRCount(chapter, temp); qDbList.Add(temp); } var pChapter = qDbList.Where(x => x.PID == "0").ToList(); foreach (var chapter in pChapter) { var tempList = qDbList.Where(x => x.PID == chapter.ID); chapter.Selects = tempList.Sum(x => x.Selects); chapter.TRs = tempList.Sum(x => x.TRs); } } return(qDbList); }