public static async Task SendPostMessageAsync(Models.Outcomes outcomes, string reqUrl) { var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(KeyName, AccessKey); var messagingFactory = MessagingFactory.Create(BaseAddress, tokenProvider); var sender = messagingFactory.CreateMessageSender(QueueName); var messageModel = new MessageModel() { TitleMessage = "New Outcome record {" + outcomes.OutcomeId + "} added at " + DateTime.UtcNow, CustomerGuid = outcomes.CustomerId, LastModifiedDate = outcomes.LastModifiedDate, URL = reqUrl + "/" + outcomes.OutcomeId, IsNewCustomer = false, TouchpointId = outcomes.LastModifiedTouchpointId }; var msg = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel)))) { ContentType = "application/json", MessageId = outcomes.CustomerId + " " + DateTime.UtcNow }; //msg.ForcePersistence = true; Required when we save message to cosmos await sender.SendAsync(msg); }
public async Task <Models.Outcomes> CreateAsync(Models.Outcomes outcomes) { if (outcomes == null) { return(null); } outcomes.SetDefaultValues(); var documentDbProvider = new DocumentDBProvider(); var response = await documentDbProvider.CreateOutcomesAsync(outcomes); return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : null); }
public async Task <ResourceResponse <Document> > CreateOutcomesAsync(Models.Outcomes outcomes) { var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(null); } var response = await client.CreateDocumentAsync(collectionUri, outcomes); return(response); }
public void Setup() { _outcome = Substitute.For <Models.Outcomes>(); _outcomePatch = Substitute.For <OutcomesPatch>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Outcomes/1e1a555c-9633-4e12-ab28-09ed60d51cb3") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _deleteOutcomesHttpTriggerService = Substitute.For <IDeleteOutcomesHttpTriggerService>(); }
public void Setup() { _outcome = Substitute.For <Models.Outcomes>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Interactions/aa57e39e-4469-4c79-a9e9-9cb4ef410382/" + $"Outcomes/d5369b9a-6959-4bd3-92fc-1583e72b7e51") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _getOutcomesByIdHttpTriggerService = Substitute.For <IGetOutcomesByIdHttpTriggerService>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); }
public void Setup() { _outcome = Substitute.For <Models.Outcomes>(); _outcomePatch = Substitute.For <OutcomesPatch>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Outcomes/1e1a555c-9633-4e12-ab28-09ed60d51cb3") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _validate = Substitute.For <IValidate>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _patchOutcomesHttpTriggerService = Substitute.For <IPatchOutcomesHttpTriggerService>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/"); }
public async Task SendToServiceBusQueueAsync(Models.Outcomes outcomes, Guid customerId, string reqUrl) { await ServiceBusClient.SendPatchMessageAsync(outcomes, customerId, reqUrl); }
public async Task SendToServiceBusQueueAsync(Models.Outcomes outcomes, string reqUrl) { await ServiceBusClient.SendPostMessageAsync(outcomes, reqUrl); }