public MicroCourseModel GetMicroCourseInfo(int subjectId, int stageId) { using (var metadb = new ModMetaEntities()) { MicroCourseModel micrcomodel = new MicroCourseModel(); tb_Code_ListTable2 subject = metadb.tb_Code_ListTable2.Where(w => w.ID == subjectId && w.Deleted == 0).FirstOrDefault(); micrcomodel.subjectID = subject.ID; micrcomodel.subjectName = subject.CodeName; micrcomodel.knowledgeList = new List <KnowledgeModel>(); List <tb_Code_Knowledge> knowlist = metadb.tb_Code_Knowledge.Where(w => w.SubjectID == subjectId && w.StageID == stageId && w.Deleted == 0 && w.ParentID == 0).OrderBy(o => o.Seq).ToList(); foreach (tb_Code_Knowledge konwledge in knowlist) { KnowledgeModel knowledgemodel = new KnowledgeModel(); knowledgemodel.ID = konwledge.ID; knowledgemodel.stage = konwledge.StageID; knowledgemodel.subject = konwledge.SubjectID; knowledgemodel.CodeName = konwledge.CodeName; knowledgemodel.Children = GetKnowlegeList(metadb, knowledgemodel.ID); micrcomodel.knowledgeList.Add(knowledgemodel); } if (CacheHelper.Get("CataIds") == null) { List <tb_Code_Knowledge> listcatas = metadb.tb_Code_Knowledge.Where(w => w.Deleted == 0 && w.SubjectID == subjectId && w.StageID == stageId).OrderBy(o => o.Seq).ToList(); CacheHelper.Insert("CataIds", listcatas); } return(micrcomodel); } }
// GET: MicroCourse public ActionResult Index(int subjectId = 2, int stageId = 2) { MicroCourseBLL mCourseBll = new MicroCourseBLL(); if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue("StageID"))) { stageId = int.Parse(CookieHelper.GetCookieValue("StageID")); } MicroCourseModel mCourseModel = mCourseBll.GetMicroCourseInfo(subjectId, stageId); ViewBag.StageID = stageId; return(View(mCourseModel)); }