All files / platform/modules/booking/src/Services StaffService.js

100% Statements 7/7
100% Branches 2/2
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32    1x       41x       41x                   12x       12x 1x         1x  
'use strict';
 
const CE = use('C2C/Exceptions');
 
class StaffService {
  static get inject() {
    return ['C2C/Repositories/StaffConnectionRepo'];
  }
 
  constructor(staffConnectionRepo) {
    this.staffConnectionRepo = staffConnectionRepo;
  }
 
  /**
   * @param {String} systemId The system ID
   * @param {Array} staffIds An array of staff IDs
   *
   * @return {void}
   */
  async checkStaffConnection(systemId, staffIds) {
    const count = await this.staffConnectionRepo.countConnectedBy({
      systemId,
      staffIds,
    });
    if (count !== staffIds.length) {
      throw CE.BadRequestException.raise('errors.staffConnectionNotExist');
    }
  }
}
 
module.exports = StaffService;