public ActionResult Prerequisites() { var courseTCs = CoursePrerequisiteService.GetAll(x => x.Test_ID != null && x.Course.IsActive).Select(x => x.Course_TC).ToList(); var courses = CourseService.GetAll() .Where(x => courseTCs.Contains(x.Course_TC)).ToList(); var sectionCourses = GroupVmService.GetSectionCourses(courses).ToList(); return(BaseView(Views.Test.Prerequisites, new PrerequisiteTestsVM { Courses = sectionCourses })); }
public ActionResult CourseRecommendations(string id) { var model = new List <FullCourseCoef>(); if (!id.IsEmpty()) { var parentTC = CourseService.GetValues(id, x => x.ParentCourse_TC); var context = new RecRepository().GetContext(); var coefs = GetCoefs(context, parentTC); if (coefs.Any()) { var preCourses = CoursePrerequisiteService.GetAll(x => x.Course_TC == id) .Select(x => x.RequiredCourse.ParentCourse_TC).ToList(); coefs = coefs.Where(x => !preCourses.Contains(x.Item1)).ToList(); model = GetCourses(coefs); } } return(View(model)); }
private List <Course> GetCourses(string entityCourseTCList, List <string> completeCourseTC) { List <Course> courses; var courseTCs = StringUtils.SafeSplit(entityCourseTCList); var unStudyCourseTCs = courseTCs .Where(x => !completeCourseTC.Contains(x)).ToList(); var prerequsisite = CoursePrerequisiteService.GetAll(x => unStudyCourseTCs.Contains(x.Course_TC) && x.RequiredCourse_TC != null && x.RequiredCourse.IsActive) .Select(x => new { x.Course_TC, x.RequiredCourse_TC }).ToList().GroupByToDictionary(x => x.Course_TC, x => x.RequiredCourse_TC); courseTCs = courseTCs.SelectMany(x => _.List(x).AddFluent(prerequsisite.GetValueOrDefault(x))) .ToList(); courseTCs = courseTCs.Distinct().ToList(); courses = CourseService.GetAll(x => courseTCs.Contains(x.Course_TC)) .ToList(); return(courses); }