Skip to content

Instantly share code, notes, and snippets.

@MaxLarue
Created July 9, 2022 15:06
Show Gist options
  • Save MaxLarue/cdc6f7218b8bb43953f361b2c5df10ec to your computer and use it in GitHub Desktop.
Save MaxLarue/cdc6f7218b8bb43953f361b2c5df10ec to your computer and use it in GitHub Desktop.
appointment-rating
@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,
@Inject(RatingServiceGateway) private readonly ratingServiceGateway: RatingServiceGateway) {}
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)
await this.ratingServicegateway.onAppointmentCreated(appointment)
return appointment
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment