/// <summary> /// Always Apply Retry pattern to make it more resilient /// </summary> private async Task CompensateIfRequired(WorkShopManagementNewVM inputModel, HttpResponseMessage httpResponse) { _logger.LogInformation("SAGA - CompensateIfRequired called"); if (httpResponse.StatusCode == HttpStatusCode.OK) { return; } _logger.LogInformation($"SAGA - httpResponse.StatusCode{httpResponse.StatusCode}"); if (IsVehicleApiRequest(httpResponse)) { _logger.LogInformation("SAGA - IsVehicleApiRequest:true"); HttpResponseMessage customerUndoResponse = await _policy .ExecuteAsync(() => _customerAPI.UndoRegister(inputModel.Customer.EmailAddress)); } else if (IsWorkshopApiRequest(httpResponse)) { _logger.LogInformation("SAGA - IsWorkshopApiRequest:true"); HttpResponseMessage vehicleUndoResponse = await _policy .ExecuteAsync(() => _vehicleAPI.UndoRegister(inputModel.Vehicle.LicenseNumber)); HttpResponseMessage customerUndoResponse = await _policy .ExecuteAsync(() => _customerAPI.UndoRegister(inputModel.Customer.EmailAddress)); } }