public ActionResult CourseDetails(int courseId) { var viewString = ViewStrings.Course_Details; // Populate TempData with necessary list data GetListData(); try { // Step 1 - Get the course and instructor by the passed Id var course = CoursesService.GetCourse(new CourseModel { IdCourse = courseId }); var instructor = UsersService.GetUser(course.CourseInstructorId.ToString()); // Step 2 - Create CourseInfoModel for course var courseInfoModel = new CourseInfoModel { Course = course, InstructorFirstName = instructor.FirstName ?? "", InstructorLastName = instructor.LastName ?? "" }; // Step 3 - Go to CourseDetails view with CourseInfoModel return(View(viewString, courseInfoModel)); } catch (Exception e) { Console.Write(e.Message); return(View(viewString, new CourseInfoModel())); } }
public ActionResult DeleteConfirmed(int id) { CourseInfoModel courseInfoModel = _iCourse.GetCourseDetails(id); _iCourse.Remove(courseInfoModel); _iCourse.Commit(); return(RedirectToAction("Index")); }
public ActionResult Edit(CourseInfoModel courseInfoModel) { if (ModelState.IsValid) { _iCourse.Update(courseInfoModel); _iCourse.Commit(); return(RedirectToAction("Index")); } return(View(courseInfoModel)); }
public ActionResult StudentHome(int courseId) { var viewString = ViewStrings.Course_StudentHome; try { // If student isn't registered for the course, redirect to an error page var currentUser = TempData[TempDataValues.CurrentUser] as UserModel; TempData.Keep(TempDataValues.CurrentUser); if (!(StudentCourseAssocService.GetAssoc(new StudentCourseAssocModel { IdCourse = courseId, IdStudent = currentUser.IdUser ?? 0 }).IdStudent > 0)) { return(RedirectToAction("InvalidRole", "Errors")); } // Step 1 - Get the course and instructor by the passed Id var course = CoursesService.GetCourse(new CourseModel { IdCourse = courseId }); var instructor = UsersService.GetUser(course.CourseInstructorId.ToString()); // Step 2 - Create CourseInfoModel for course var courseInfoModel = new CourseInfoModel { Course = course, InstructorFirstName = instructor.FirstName ?? "", InstructorLastName = instructor.LastName ?? "" }; // Step 3 - Get participants list courseInfoModel.Participants = new List <Interfaces.Models.IUserModel>(); foreach (var student in StudentCourseAssocService.ListAssocs(new StudentCourseAssocModel { IdCourse = courseId })) { // Add each student registered for the course to the participants list courseInfoModel.Participants.Add(UsersService.GetUser(student.IdStudent.ToString())); } // TODO: Step 4- Get Assignments by courseId (Add to CourseInfoModel) // Step 4 - Go to StudentHome view with CourseInfoModel return(View(viewString, courseInfoModel)); } catch (Exception e) { Console.Write(e.Message); return(View(viewString, new CourseInfoModel())); } }
// GET: CourseInfo/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseInfoModel courseInfoModel = _iCourse.GetCourseDetails(id); if (courseInfoModel == null) { return(HttpNotFound()); } return(View(courseInfoModel)); }
public void Remove(CourseInfoModel courseInfoModel) { throw new NotImplementedException(); }
public void Update(CourseInfoModel courseInfoModel) { _context.Entry(courseInfoModel).State = EntityState.Modified; }
public void Insert(CourseInfoModel courseInfoModel) { _context.CourseInfoEntity.Add(courseInfoModel); }