// GET: ShowPaths //@Html.ActionLink("Show Courses", "GetPathDetails", new { id=item.path_id}) public ActionResult Index() { if (Session["id"] == null) { Session["timeout"] = "Session Expired....."; return(RedirectToAction("Index", "Login")); } else { Learning_strategy_class obj = new Learning_strategy_class(); obj.delete_Null_Path(); List <Snap97_NS_CS.Learning_path_masted> master_path = obj.Get_learning_path((int)Session["id"]); List <Learning_path_masted> local_master_path = new List <Learning_path_masted>(); foreach (var element in master_path) { local_master_path.Add(new Learning_path_masted() { learner_id = element.learner_id, path_id = element.path_id, pathname = element.pathName, creation_date = element.creation_date }); } return(View(local_master_path)); } }
public ActionResult CreatePath(string pathname) { if (Session["id"] == null) { Session["timeout"] = "Session Expired....."; return(RedirectToAction("Index", "Login")); } else { Learning_strategy_class obj = new Learning_strategy_class(); obj.Name_my_path((int)Session["PathId"], pathname); foreach (var i in c) { obj.Add_course_to_lp((int)Session["PathId"], i.course_id); } c.Clear(); obj.delete_Null_Path(); Session["PathId"] = null; return(RedirectToAction("index", "course")); } }
public ActionResult Index(string searchTerm, string currentFilter, string sortOrder, int?page) { ViewData["Message"] = Session["Add_Message"]; Learning_strategy_class obj = new Learning_strategy_class(); obj.delete_Null_Path(); if (Session["id"] == null) { Session["timeout"] = "Session Expired....."; return(RedirectToAction("Index", "Login")); } else { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; if (searchTerm != null) { page = 1; } else { searchTerm = currentFilter; } ViewBag.CurrentFilter = searchTerm; int i = obj.Get_new_pathid((int)Session["id"]); if (i.Equals(0)) { obj.Create_learning_path((int)Session["id"]); i = obj.Get_new_pathid((int)Session["id"]); } Session["PathId"] = i; IEnumerable <Snap97_NS_CS.Course> courseobj = obj.GetCourses().Where(x => searchTerm == null || x.course_name.ToUpper().Contains(searchTerm.ToUpper()) || x.course_description.ToUpper().Contains(searchTerm.ToUpper())); List <Course> c = new List <Course>(); foreach (var course in courseobj) { c.Add( new Course() { course_id = course.course_id, course_name = course.course_name, course_description = course.course_description, course_duration = course.course_duration, course_lvl = (course_levels)course.course_lvl }); } switch (sortOrder) { case "name_desc": c = c.OrderByDescending(s => s.course_name).ToList(); break; default: c = c.OrderBy(s => s.course_name).ToList(); break; } int pageSize = 5; int pageNumber = (page ?? 1); return(View(c.ToPagedList(pageNumber, pageSize))); } }