private AFECustomerChangeNotificationResponse NotifyChangeToAfe(Models.ParameterModels.CustomerLoadOrMatch customer, DateTime processedDatetime, long id) { // var afeNotificationRequest = new AFECustomerChangeNotificationRequest { notification = new AFECustomerChangeNotification { Id = id.ToString(), // customerId.ToString(), Source = "CWS", Code = customer.Customer.SystemSource, Value = customer.Customer.SystemId, OriginatingSource = customer.Customer.SystemSource.Substring(0, 3), // Timestamp = processedDatetime.ToString() // AFE Endpoint supported Timestamp format Timestamp = processedDatetime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'") //"2018-01-24T12:41:30.937Z" // wether API Success or Fail need to update the database, so windows service will pick up and process(Windows service need to be build) } }; // Assign local delegates to log outcome ... _afeWebClient.OnCompleted = LogAfeCallSuccess; _afeWebClient.OnError = LogAfeCallException; // Call AfeWebClient to invoke the callback var afeNotificationResponse = _afeWebClient.CustomerChange(afeNotificationRequest); return(afeNotificationResponse); }
public IHttpActionResult PostCustomer(Models.ParameterModels.CustomerLoadOrMatch customer ) { var mappedCustomer = Mapper.Map <WebApiServices.Models.Customer.CustomerLoadOrMatch>(customer); // customer.AccessControl = _clientScopeService.VerifyUserHasAccessToGroupCode(customer.AccessControl, Scope.CUSTOMER_LOAD); int customerId; DateTime processedDatetime; var id = _mciRequestService.SaveCustomer(mappedCustomer, out customerId, out processedDatetime); // This is the [RecordID] PKey of the [MCI_CUSTOMER_API_LANDING] table string message = (id > 0) ? $"Customer loaded successfully. [Id={id}]" : $"Customer load failed. [Id={id}]"; // Callback to Afe WebApi notify of customer change : No async call currently // //Task.Factory.StartNew(() => //{ AFECustomerChangeNotificationResponse afeNotificationResponse = NotifyChangeToAfe(customer, processedDatetime, id); //}; // Update local Afe log table to reflect the call above ... CreateAfeCallbackDbLog(customerId, afeNotificationResponse); return(Ok(message)); }