public IActionResult CreateCourse(CourseModel model) { if (ModelState.IsValid) { _courseservices.CreateCourse(model); return(RedirectToAction("Index")); } return(View(model)); }
public bool SaveCourse(Course course) { try { if (_courseServices.GetCourseById(course.Id) == null) { var courseId = _courseServices.CreateCourse(course.Name, course.NaturalIdentifier, course.EctsCredits).Id; _courseServices.UpdateLecturers(courseId, course.LecturersInCharge); _courseServices.UpdateStudents(courseId, course.StudentsEnrolled); } else { _courseServices.UpdateCourse(course.Id, course.Name, course.NaturalIdentifier, course.EctsCredits); _courseServices.UpdateLecturers(course.Id, course.LecturersInCharge); _courseServices.UpdateStudents(course.Id, course.StudentsEnrolled); } return(true); } catch (Exception ex) { return(false); } }