Ejemplo n.º 1
0
        public void JoinCourse(ICourse course)
        {
            Validator.CheckIfNull(course, "Parameter should not be null!");

            course.AddStudent(this);
            this.courses.Add(course);
        }
Ejemplo n.º 2
0
        public void JoinCourse(ICourse course)
        {
            Validator.CheckIfNull(course);

            course.AddStudent(this);
            this.courses.Add(course.CourseName);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        // POST: {courseId}/{studentId}
        // Model Binding
        public async Task <IActionResult> AddStudentToCourse(int courseId, int studentId)
        {
            await _course.AddStudent(studentId, courseId);

            return(Ok());
        }