public static async Task SendPostMessageAsync(Models.ActionPlan actionPlan, 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 Action Plan record {" + actionPlan.ActionPlanId + "} added at " + DateTime.UtcNow,
                CustomerGuid     = actionPlan.CustomerId,
                LastModifiedDate = actionPlan.LastModifiedDate,
                URL           = reqUrl + "/" + actionPlan.ActionPlanId,
                IsNewCustomer = false,
                TouchpointId  = actionPlan.LastModifiedTouchpointId
            };

            var msg = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel))))
            {
                ContentType = "application/json",
                MessageId   = actionPlan.CustomerId + " " + DateTime.UtcNow
            };

            //msg.ForcePersistence = true; Required when we save message to cosmos
            await sender.SendAsync(msg);
        }
        public async Task <ResourceResponse <Document> > CreateActionPlanAsync(Models.ActionPlan actionPlan)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            if (client == null)
            {
                return(null);
            }

            var response = await client.CreateDocumentAsync(collectionUri, actionPlan);

            return(response);
        }
示例#3
0
        public async Task <Models.ActionPlan> CreateAsync(Models.ActionPlan actionPlan)
        {
            if (actionPlan == null)
            {
                return(null);
            }

            actionPlan.SetDefaultValues();

            var documentDbProvider = new DocumentDBProvider();

            var response = await documentDbProvider.CreateActionPlanAsync(actionPlan);

            return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : null);
        }
示例#4
0
        public void Setup()
        {
            _actionPlan = Substitute.For <Models.ActionPlan>();

            _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/" +
                            $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51")
            };

            _log            = Substitute.For <ILogger>();
            _resourceHelper = Substitute.For <IResourceHelper>();
            _getActionPlanByIdHttpTriggerService = Substitute.For <IGetActionPlanByIdHttpTriggerService>();
            _httpRequestMessageHelper            = Substitute.For <IHttpRequestMessageHelper>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
        }
示例#5
0
        public void Setup()
        {
            _actionPlan      = Substitute.For <Models.ActionPlan>();
            _actionPlanPatch = Substitute.For <ActionPlanPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"ActionPlans/1e1a555c-9633-4e12-ab28-09ed60d51cb3")
            };

            _log                               = Substitute.For <ILogger>();
            _resourceHelper                    = Substitute.For <IResourceHelper>();
            _validate                          = Substitute.For <IValidate>();
            _httpRequestMessageHelper          = Substitute.For <IHttpRequestMessageHelper>();
            _patchActionPlanHttpTriggerService = Substitute.For <IPatchActionPlanHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
            _patchActionPlanHttpTriggerService.PatchResource(Arg.Any <string>(), _actionPlanPatch).Returns(_actionPlan.ToString());
        }
示例#6
0
 public async Task SendToServiceBusQueueAsync(Models.ActionPlan actionPlan, string reqUrl)
 {
     await ServiceBusClient.SendPostMessageAsync(actionPlan, reqUrl);
 }
示例#7
0
 public async Task SendToServiceBusQueueAsync(Models.ActionPlan actionPlan, Guid customerId, string reqUrl)
 {
     await ServiceBusClient.SendPatchMessageAsync(actionPlan, customerId, reqUrl);
 }