private async Task CheckAndAssignOperatives(int workOrderId, IEnumerable <string> operativePayrollIds, Operative[] operatives) { if (operatives.Any()) { var jobPercentage = 100.0 / operatives.Length; _logger.LogInformation($"Updating operatives [{string.Join(", ", operativePayrollIds)}] to jobPercentage {jobPercentage} for workOrderId: {workOrderId}"); await _operativesGateway.AssignOperatives(workOrderId, OperativeAssignmentType.Automatic, operatives.Select(o => (o.Id, jobPercentage)).ToArray()); } else { _logger.LogInformation($"Gateway did not return any operatives for workorderId: {workOrderId}, though {string.Join(", ", operativePayrollIds)} were searched"); } }
public async Task Execute(JobStatusUpdate jobStatusUpdate) { var workOrder = jobStatusUpdate.RelatedWorkOrder; workOrder.VerifyCanAssignOperative(); if (!await workOrder.CanAssignOperative(_scheduleOfRatesGateway)) { ThrowHelper.ThrowUnsupported(Resources.NonOperativeContractor); } var operativeIds = jobStatusUpdate.OperativesAssigned.Select(oa => (int.Parse(oa.Identification.Number), oa.CalculatedBonus ?? 100)); _logger.LogInformation($"Manually assigning operatives [{string.Join(", ", operativeIds.Select(o => o.Item1))}] to work order {workOrder.Id}"); await _operativesGateway.AssignOperatives(workOrder.Id, OperativeAssignmentType.Manual, operativeIds.ToArray()); }