public static async Task SendPostMessageAsync(Models.WebChat webChat, 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 WebChat record {" + webChat.WebChatId + "} added at " + DateTime.UtcNow, CustomerGuid = webChat.CustomerId, LastModifiedDate = webChat.LastModifiedDate, URL = reqUrl + "/" + webChat.WebChatId, IsNewCustomer = false, TouchpointId = webChat.LastModifiedTouchpointId }; var msg = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel)))) { ContentType = "application/json", MessageId = webChat.CustomerId + " " + DateTime.UtcNow }; //msg.ForcePersistence = true; Required when we save message to cosmos await sender.SendAsync(msg); }
public async Task <ResourceResponse <Document> > UpdateWebChatAsync(Models.WebChat webchat) { var documentUri = DocumentDBHelper.CreateDocumentUri(webchat.WebChatId.GetValueOrDefault()); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(null); } var response = await client.ReplaceDocumentAsync(documentUri, webchat); return(response); }
public async Task <ResourceResponse <Document> > CreateWebChatAsync(Models.WebChat webchat) { var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(null); } var response = await client.CreateDocumentAsync(collectionUri, webchat); return(response); }
public async Task <Models.WebChat> CreateAsync(Models.WebChat webChat) { if (webChat == null) { return(null); } webChat.SetDefaultValues(); var documentDbProvider = new DocumentDBProvider(); var response = await documentDbProvider.CreateWebChatAsync(webChat); return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : null); }
public async Task <Models.WebChat> UpdateAsync(Models.WebChat webChat, WebChatPatch webChatPatch) { if (webChat == null) { return(null); } webChat.Patch(webChatPatch); webChat.SetDefaultValues(); var documentDbProvider = new DocumentDBProvider(); var response = await documentDbProvider.UpdateWebChatAsync(webChat); var responseStatusCode = response.StatusCode; return(responseStatusCode == HttpStatusCode.OK ? webChat : null); }
public void Setup() { _webChat = Substitute.For <Models.WebChat>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Interactions/1e1a555c-9633-4e12-ab28-09ed60d51cb3/" + $"WebChats/d5369b9a-6959-4bd3-92fc-1583e72b7e51") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _getWebChatByIdHttpTriggerService = Substitute.For <IGetWebChatByIdHttpTriggerService>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); }
public void Setup() { _webChat = Substitute.For <Models.WebChat>(); _webChatPatch = Substitute.For <WebChatPatch>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Interactions/1e1a555c-9633-4e12-ab28-09ed60d51cb3/" + $"WebChats/1e1a555c-9633-4e12-ab28-09ed60d51cb3") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _validate = Substitute.For <IValidate>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _patchWebChatHttpTriggerService = Substitute.For <IPatchWebChatHttpTriggerService>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/"); }
public async Task SendToServiceBusQueueAsync(Models.WebChat webChat, Guid customerId, string reqUrl) { await ServiceBusClient.SendPatchMessageAsync(webChat, customerId, reqUrl); }
public async Task SendToServiceBusQueueAsync(Models.WebChat webChat, string reqUrl) { await ServiceBusClient.SendPostMessageAsync(webChat, reqUrl); }