protected override async Task RunCommand(CreateStudent command, CancellationToken cancellationToken) { var newCourse = new Student(command.StudentId, command.StudentFirstname, command.StudentLastname); await _unitOfWork.StudentsRepository.CreateAsync(newCourse, cancellationToken); await _unitOfWork.CommitAsync(cancellationToken); }
protected override async Task RunCommand(CreateCourse command, CancellationToken cancellationToken) { var newCourse = new Course(command.CourseId, command.CourseTitle); await _unitOfWork.CoursesRepository.CreateAsync(newCourse, cancellationToken); await _unitOfWork.CommitAsync(cancellationToken); }
protected override async Task RunCommand(Withdraw command, CancellationToken cancellationToken) { var course = await _unitOfWork.CoursesRepository.FindByIdAsync(command.CourseId, cancellationToken); var student = await _unitOfWork.StudentsRepository.FindByIdAsync(command.StudentId, cancellationToken); student.Withdraw(course); await _unitOfWork.CommitAsync(cancellationToken); }