public IActionResult EditCourse(viewModelStudentCourse viewModel) { //get the UID from the Session int uID = Convert.ToInt32(HttpContext.Session.GetString("uID")); //reads from the session //get the Course object from the DB using the DALCourse class DALCourses dp = new DALCourses(configuration); DALStudent ds = new DALStudent(configuration); Student stu = ds.getStudent(uID); dp.UpdateCourses(viewModel.AddedCourse.ClassID.ToString(), viewModel.AddedCourse.UID); viewModelStudentCourse courseList = new viewModelStudentCourse(); courseList.UID = stu.UID; courseList.FirstName = stu.FirstName; courseList.LastName = stu.LastName; courseList.StudentEmail = stu.StudentEmail; courseList.Courses = new Courselist(); courseList.Courses.Courses = dp.GetCourseAvailableForStudent(uID); //send the view // return View(courseList); return(RedirectToAction("EditCourse", new { uID = uID })); }
public IActionResult EditCourse(int?id) { //get the UID from the Session int uID = Convert.ToInt32(HttpContext.Session.GetString("uID")); //reads from the session //get the Course object from the DB using the DALCourse class DALCourses dp = new DALCourses(configuration); DALStudent ds = new DALStudent(configuration); Student stu = ds.getStudent(uID); viewModelStudentCourse courseList = new viewModelStudentCourse(); courseList.UID = stu.UID; courseList.AddedCourse = new Courses(); courseList.AddedCourse.UID = stu.UID; /// This is new courseList.SelectedCourses = new Courselist(); courseList.SelectedCourses.Courses = dp.getCourses(stu.UID.ToString()); courseList.FirstName = stu.FirstName; courseList.LastName = stu.LastName; courseList.StudentEmail = stu.StudentEmail; courseList.Courses = new Courselist(); courseList.Courses.Courses = dp.GetCourseAvailableForStudent(uID); //send the view return(View(courseList)); }