public void JoinCourse(ICourse course) { Validator.CheckIfNull(course, "Parameter should not be null!"); course.AddStudent(this); this.courses.Add(course); }
public void JoinCourse(ICourse course) { Validator.CheckIfNull(course); course.AddStudent(this); this.courses.Add(course.CourseName); }
public void JoinCourse(ICourse course) { Validator.NullCheck(course, "Course"); if (Validator.IsPartOfCollection(this.courses, course)) { throw new InvalidOperationException($"{this} is already part of {course}"); } course.AddStudent(this); this.courses.Add(course); }
public async Task <Student> Create(NewStudentDto inboundData) { // Add the student Student student = new Student() { FirstName = inboundData.Name.Split(" ").First <string>(), LastName = inboundData.Name.Split(" ").Last <string>(), DateOfBirth = inboundData.Dob }; _context.Entry(student).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); // Use the Courses Service to get a course from the course service Course course = await _courses.GetOneByCourseCode(inboundData.CourseCode); // Use the Courses Service to add an enrollment for the student and course await _courses.AddStudent(course.Id, student.Id); return(student); }
// POST: {courseId}/{studentId} // Model Binding public async Task <IActionResult> AddStudentToCourse(int courseId, int studentId) { await _course.AddStudent(studentId, courseId); return(Ok()); }