Last active
July 9, 2022 15:52
-
-
Save MaxLarue/fe54baa5491cdb7e7d5f5a34322b1a2a to your computer and use it in GitHub Desktop.
appointment with events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppointmentService { | |
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>, | |
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService, | |
@Inject(EVENT_PUBLISHER_TOKEN) private readonly eventPublisher: EventPublisher) {} | |
async create(values: DeepPartial<Appointment>, currentUser: User) { | |
await this.appointmentPermissionService.verifyCanCreate(currentUser, values) | |
const appointment = await this.repository.save(values) | |
await this.eventPublisher.publish(makeAppointmentCreatedEvent(appointment.id)) | |
return appointment | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment