public async Task UpdateWorkOrderDetails(int workOrderId) { _logger.LogInformation($"UpdateWorkOrderDetails for workOrderId: {workOrderId}"); var order = await SelectOrder(workOrderId); if (order.theBookings.IsNullOrEmpty()) { return; } var theBooking = ExtractBooking(order);; var theResources = theBooking.theResources; if (theResources.IsNullOrEmpty()) { return; } var operativePayrollIds = theResources.Select(r => r.externalResourceCode); var operatives = (await Task.WhenAll(operativePayrollIds.Select(i => _operativesGateway.GetAsync(i)))) .Where(o => o != null) .ToArray(); await CheckAndAssignOperatives(workOrderId, operativePayrollIds, operatives); await _appointmentsGateway.SetTimedBooking( workOrderId, DrsHelpers.ConvertToDrsTimeZone(theBooking.planningWindowStart), DrsHelpers.ConvertToDrsTimeZone(theBooking.planningWindowEnd), theBooking.bookingReason ); _logger.LogInformation($"WorkOrder {workOrderId}: successfully set timed booking - start: {theBooking.planningWindowStart} end: {theBooking.planningWindowEnd}"); await _repairsGateway.UpdateWorkOrderAttributes(workOrderId, theBooking.GetPlannerComments()); }
public async Task <string> ConfirmBooking(bookingConfirmation bookingConfirmation) { _logger.LogInformation($"ConfirmBooking for bookingId: {bookingConfirmation.bookingId}"); var serialisedBookings = JsonConvert.SerializeObject(bookingConfirmation); _logger.LogInformation(serialisedBookings); var workOrderId = (int)bookingConfirmation.primaryOrderNumber; await _appointmentsGateway.SetTimedBooking( workOrderId, bookingConfirmation.planningWindowStart, bookingConfirmation.planningWindowEnd, bookingConfirmation.bookingReason ); await _drsService.UpdateWorkOrderDetails(workOrderId); await AddAuditTrail(workOrderId, bookingConfirmation); return(Resources.DrsBackgroundService_BookingAccepted); }