import { Injectable } from '@angular/core' ; import { RequestsService } from "./requests.service" ; import * as _ from "lodash" ; @ Injectable ( ) export class RequestsUtilsService { constructor ( private requestsService ) { } getAllRequests ( requestList ) { let list = [ ] ; _ . each ( requestList , ( requestId ) => { list . push ( this . requestsService . getRequest ( requestId ) ) ; } ) ; return Promise . all ( list ) ; } approveAllRequests ( selection ) { console . log ( selection ) ; let list = [ ] ; _ . each ( selection , ( request ) => { list . push ( this . requestsService . approveRequest ( request . id ) ) ; } ) ; return Promise . all ( list ) ; } denyAllRequests ( selection ) { console . log ( selection ) ; let list = [ ] ; _ . each ( selection , ( request ) => { list . push ( this . requestsService . denyRequest ( request . id ) ) ; } ) ; return Promise . all ( list ) ; } }