예제 #1
0
        public async Task <Result> Execute(Student student, Guid courseId)
        {
            var courseResult = await _courseLoader.GetCourse(courseId);

            Result result;

            if (courseResult.IsSuccess)
            {
                Course course = courseResult;
                result = course.RegisterStudent(student.Id);
                if (result.IsSuccess)
                {
                    result = await _courseLoader.UpdateCourse(course);
                }
                await _signUpNotifier.NotifyOfRegistrationOutcome(student, course, result.IsSuccess);
            }
            else
            {
                result = courseResult;
            }
            return(result);
        }
        public async Task <Result> Execute(Guid studentId, Guid courseId)
        {
            var courseResult = await _courseLoader.GetCourse(courseId);

            Result result;

            if (courseResult.IsSuccess)
            {
                Course course = courseResult;
                result = course.RegisterStudent(studentId);
                if (result.IsSuccess)
                {
                    result = await _courseLoader.UpdateCourse(course);
                }
            }
            else
            {
                result = courseResult;
            }

            return(result);
        }