Last active
July 9, 2022 14:56
-
-
Save MaxLarue/a44fadce5cb5c66df575fa3d77fc845f to your computer and use it in GitHub Desktop.
appointment-service 2
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(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