Created
June 24, 2021 16:51
-
-
Save aatifbandey/94acab7f632739163c8da29af2e00853 to your computer and use it in GitHub Desktop.
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
let employees = [ | |
{ | |
id: 1, | |
email: '[email protected]', | |
firstName: 'First1', | |
lastName: 'Last1', | |
}, | |
{ | |
id: 2, | |
email: '[email protected]', | |
firstName: 'First2', | |
lastName: 'Last2', | |
}, | |
{ | |
id: 3, | |
email: '[email protected]', | |
firstName: 'First3', | |
lastName: 'Last3', | |
}, | |
]; | |
const _ = require('lodash'); | |
function paySalary(call) { | |
let employeeIdList = call.request.employeeIdList; | |
_.each(employeeIdList, function (employeeId) { | |
console.log("Employeed Id", employeeId); | |
let employee = _.find(employees, { id: employeeId }); | |
console.log(employee); | |
if (employee != null) { | |
let responseMessage = "Salary paid for ".concat( | |
employee.firstName, | |
", ", | |
employee.lastName); | |
call.write({ message: responseMessage }); | |
} | |
else{ | |
call.write({message: "Employee with Id " + employeeId + " not found in record"}); | |
} | |
}); | |
call.end(); | |
} | |
exports.paySalary = paySalary; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment