Skip to content

Instantly share code, notes, and snippets.

@MaxLarue
Last active July 9, 2022 14:56
Show Gist options
  • Save MaxLarue/a44fadce5cb5c66df575fa3d77fc845f to your computer and use it in GitHub Desktop.
Save MaxLarue/a44fadce5cb5c66df575fa3d77fc845f to your computer and use it in GitHub Desktop.
appointment-service 2
@Injectable()
export class AppointmentService {
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>,
@Inject(QuotationService) private readonly quotationService: QuotationService,
@Inject(WorkOrderService) private readonly workOrderService: WorkOrderService,
@Inject(NotificationService) private readonly notificationService: NotificationService,
@Inject(StatusChangeHistoryService) private readonly statusChangeHistoryService: StatusChangeHistoryService,
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService) {}
async create(values: DeepPartial<Appointment>, currentUser: User) {
await this.appointmentPermissionService.verifyCanCreate(currentUser, values)
const appointment = await this.repository.save(values)
await this.quotationService.onAppointmentCreated(appointment)
await this.workOrderService.onAppointmentCreated(appointment)
await this.statusChangeHistoryService.onAppointmentCreated(appointment)
await this.notificationService.onAppointmentCreated(appointment)
return appointment
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment