public async Task PostDiversityHttpTrigger_ReturnsStatusCodeUnprocessableEntity_WhenDiversityHasFailedValidation()
        {
            var validationResults = new List <ValidationResult> {
                new ValidationResult("Customer Id is Required")
            };

            _validate.ValidateResource(Arg.Any <Models.Diversity>()).Returns(validationResults);

            var result = await RunFunction(ValidCustomerId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual((HttpStatusCode)422, result.StatusCode);
        }
示例#2
0
        public async Task PostContactHttpTrigger_ReturnsStatusCodeUnprocessableEntity_WhenContactHasFailedValidation()
        {
            _httpRequestMessageHelper.GetContactDetailsFromRequest <Models.ContactDetails>(_request).Returns(Task.FromResult(_contactDetails).Result);

            var validationResults = new List <ValidationResult> {
                new ValidationResult("contactDetail Id is Required")
            };

            _validate.ValidateResource(Arg.Any <Models.ContactDetails>(), _contactDetails, true).Returns(validationResults);

            var result = await RunFunction(ValidCustomerId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual((HttpStatusCode)204, result.StatusCode);
        }
示例#3
0
        public async Task PatchGoalHttpTrigger_ReturnsStatusCodeUnprocessableEntity_WhenGoalHasFailedValidation()
        {
            _httpRequestMessageHelper.GetGoalFromRequest <GoalPatch>(_request).Returns(Task.FromResult(_goalPatch).Result);

            var validationResults = new List <ValidationResult> {
                new ValidationResult("interaction Id is Required")
            };

            _validate.ValidateResource(Arg.Any <GoalPatch>(), false).Returns(validationResults);

            var result = await RunFunction(ValidCustomerId, ValidInteractionId, ValidGoalId, ValidActionPlanId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual((HttpStatusCode)422, result.StatusCode);
        }
        public async Task PatchAdviserDetailHttpTrigger_ReturnsStatusCodeUnprocessableEntity_WhenAdviserDetailHasFailedValidation()
        {
            _httpRequestMessageHelper.GetAdviserDetailFromRequest <Models.AdviserDetailPatch>(_request).Returns(Task.FromResult(_addressPatch).Result);

            var validationResults = new List <ValidationResult> {
                new ValidationResult("address Id is Required")
            };

            _validate.ValidateResource(Arg.Any <Models.AdviserDetailPatch>(), false).Returns(validationResults);

            var result = await RunFunction(ValidAdviserDetailId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual((HttpStatusCode)422, result.StatusCode);
        }
示例#5
0
        public async Task PostSessionHttpTrigger_ReturnsStatusCodeUnprocessableEntity_WhenSessionHasFailedValidation()
        {
            _httpRequestMessageHelper.GetSessionFromRequest <Models.Session>(_request).Returns(Task.FromResult(_session).Result);

            var validationResults = new List <ValidationResult> {
                new ValidationResult("interaction Id is Required")
            };

            _validate.ValidateResource(Arg.Any <Models.Session>()).Returns(validationResults);

            var result = await RunFunction(ValidCustomerId, ValidInteractionId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual((HttpStatusCode)422, result.StatusCode);
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "AdviserDetails")] HttpRequestMessage req, ILogger log,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPostAdviserDetailHttpTriggerService adviserDetailsPostService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Post Adviser Detail C# HTTP trigger function processed a request. " + touchpointId);

            Models.AdviserDetail adviserDetailRequest;

            try
            {
                adviserDetailRequest = await httpRequestMessageHelper.GetAdviserDetailFromRequest <Models.AdviserDetail>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (adviserDetailRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            adviserDetailRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(adviserDetailRequest, true);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var adviserDetail = await adviserDetailsPostService.CreateAsync(adviserDetailRequest);

            return(adviserDetail == null
                ? HttpResponseMessageHelper.BadRequest()
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(adviserDetail)));
        }
        public static async Task <HttpResponseMessage> RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "customers/{customerId}/ContactDetails/")] HttpRequestMessage req, ILogger log,
                                                                string customerId,
                                                                [Inject] IResourceHelper resourceHelper,
                                                                [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                                [Inject] IValidate validate,
                                                                [Inject] IPostContactDetailsHttpTriggerService contactdetailsPostService,
                                                                [Inject] IDocumentDBProvider provider)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function Post Contact processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            Models.ContactDetails contactdetailsRequest;
            try
            {
                contactdetailsRequest = await httpRequestMessageHelper.GetContactDetailsFromRequest <Contact.Models.ContactDetails>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (contactdetailsRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            contactdetailsRequest.SetIds(customerGuid, touchpointId);

            var errors = validate.ValidateResource(contactdetailsRequest, null, true);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesContactDetailsExist = contactdetailsPostService.DoesContactDetailsExistForCustomer(customerGuid);

            if (doesContactDetailsExist)
            {
                return(HttpResponseMessageHelper.Conflict());
            }

            if (!string.IsNullOrEmpty(contactdetailsRequest.EmailAddress))
            {
                var contacts = await provider.GetContactsByEmail(contactdetailsRequest.EmailAddress);

                if (contacts != null)
                {
                    foreach (var contact in contacts)
                    {
                        var isReadOnly = await provider.DoesCustomerHaveATerminationDate(contact.CustomerId.GetValueOrDefault());

                        if (!isReadOnly)
                        {
                            //if a customer that has the same email address is not readonly (has date of termination)
                            //then email address on the request cannot be used.
                            return(HttpResponseMessageHelper.Conflict());
                        }
                    }
                }
            }

            var contactDetails = await contactdetailsPostService.CreateAsync(contactdetailsRequest);

            if (contactDetails != null)
            {
                await contactdetailsPostService.SendToServiceBusQueueAsync(contactDetails, ApimURL);
            }

            return(contactDetails == null
                ? HttpResponseMessageHelper.BadRequest(customerGuid)
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(contactDetails)));
        }
示例#8
0
        public static async Task <HttpResponseMessage> RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "customers/{customerId}/ContactDetails/{contactid}")] HttpRequestMessage req, ILogger log,
                                                                string customerId, string contactid,
                                                                [Inject] IResourceHelper resourceHelper,
                                                                [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                                [Inject] IValidate validate,
                                                                [Inject] IPatchContactDetailsHttpTriggerService contactdetailsPatchService,
                                                                [Inject] IDocumentDBProvider provider)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function Patch Contact processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(contactid, out var contactGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(contactGuid));
            }

            ContactDetailsPatch contactdetailsPatchRequest;

            try
            {
                contactdetailsPatchRequest = await httpRequestMessageHelper.GetContactDetailsFromRequest <ContactDetailsPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (contactdetailsPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            contactdetailsPatchRequest.LastModifiedTouchpointId = touchpointId;

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var contactdetails = await contactdetailsPatchService.GetContactDetailsForCustomerAsync(customerGuid, contactGuid);

            if (contactdetails == null)
            {
                return(HttpResponseMessageHelper.NoContent(contactGuid));
            }

            var errors = validate.ValidateResource(contactdetailsPatchRequest, contactdetails, false);

            if (!string.IsNullOrEmpty(contactdetailsPatchRequest.EmailAddress))
            {
                var contacts = await provider.GetContactsByEmail(contactdetailsPatchRequest.EmailAddress);

                if (contacts != null)
                {
                    foreach (var contact in contacts)
                    {
                        var isReadOnly = await provider.DoesCustomerHaveATerminationDate(contact.CustomerId.GetValueOrDefault());

                        if (!isReadOnly && contact.CustomerId != contactdetails.CustomerId)
                        {
                            //if a customer that has the same email address is not readonly (has date of termination)
                            //then email address on the request cannot be used.
                            return(HttpResponseMessageHelper.Conflict());
                        }
                    }
                }
            }

            // Set Digital account properties so that contentenhancer can queue change on digital identity topic.
            var diaccount = await provider.GetIdentityForCustomerAsync(contactdetails.CustomerId.Value);

            if (diaccount != null)
            {
                if (contactdetailsPatchRequest.EmailAddress == string.Empty)
                {
                    if (errors == null)
                    {
                        errors = new List <System.ComponentModel.DataAnnotations.ValidationResult>();
                    }
                    errors.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Email Address cannot be removed because it is associated with a Digital Account", new List <string>()
                    {
                        "EmailAddress"
                    }));
                    return(HttpResponseMessageHelper.UnprocessableEntity(errors));
                }

                if (!string.IsNullOrEmpty(contactdetails.EmailAddress) && !string.IsNullOrEmpty(contactdetailsPatchRequest.EmailAddress) && contactdetails.EmailAddress?.ToLower() != contactdetailsPatchRequest.EmailAddress?.ToLower() && diaccount.IdentityStoreId.HasValue)
                {
                    contactdetails.SetDigitalAccountEmailChanged(contactdetailsPatchRequest.EmailAddress?.ToLower(), diaccount.IdentityStoreId.Value);
                }
            }

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var updatedContactDetails = await contactdetailsPatchService.UpdateAsync(contactdetails, contactdetailsPatchRequest);

            if (updatedContactDetails != null)
            {
                await contactdetailsPatchService.SendToServiceBusQueueAsync(updatedContactDetails, customerGuid, ApimURL);
            }

            return(updatedContactDetails == null?
                   HttpResponseMessageHelper.BadRequest(contactGuid) :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedContactDetails)));
        }
        public async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Customers/{customerId}/Subscriptions")] HttpRequest req, ILogger log, string customerId)
        {
            var touchpointId = _httpRequestHelper.GetDssTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header");
                return(_httpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function processed a request. By Touchpoint " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(customerGuid));
            }

            Models.Subscriptions subscriptionsRequest;

            try
            {
                subscriptionsRequest = await _httpRequestHelper.GetResourceFromRequest <Models.Subscriptions>(req);
            }
            catch (JsonSerializationException ex)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (subscriptionsRequest == null)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(req));
            }

            subscriptionsRequest.SetIds(customerGuid, touchpointId);

            var errors = _validate.ValidateResource(subscriptionsRequest);

            if (errors != null && errors.Any())
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await _resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(_httpResponseMessageHelper.NoContent(customerGuid));
            }

            var doesSubscriptionExist = await _resourceHelper.DoesSubscriptionExist(customerGuid, touchpointId);

            if (doesSubscriptionExist.HasValue)
            {
                var duplicateError = _validate.ValidateResultForDuplicateSubscriptionId(doesSubscriptionExist.GetValueOrDefault());
                return(_httpResponseMessageHelper.Conflict());
            }

            var subscriptions = await _subscriptionsPostService.CreateAsync(subscriptionsRequest);

            return(subscriptions == null
                ? _httpResponseMessageHelper.BadRequest(customerGuid)
                : _httpResponseMessageHelper.Created(JsonHelper.SerializeObject(subscriptions)));
        }
        public async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/Interactions/{interactionId}")] HttpRequest req, ILogger log, string customerId, string interactionId)
        {
            var touchpointId = _httpRequestMessageHelper.GetDssTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header.");
                return(_httpResponseMessageHelper.BadRequest());
            }

            var ApimURL = _httpRequestMessageHelper.GetDssApimUrl(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(_httpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Patch Interaction C# HTTP trigger function processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(interactionId, out var interactionGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(interactionGuid));
            }

            InteractionPatch interactionPatchRequest;

            try
            {
                interactionPatchRequest = await _httpRequestMessageHelper.GetResourceFromRequest <Models.InteractionPatch>(req);
            }
            catch (JsonException ex)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (interactionPatchRequest == null)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(req));
            }

            interactionPatchRequest.LastModifiedTouchpointId = touchpointId;

            var errors = _validate.ValidateResource(interactionPatchRequest);

            if (errors != null && errors.Any())
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await _resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(_httpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await _resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(_httpResponseMessageHelper.Forbidden(customerGuid));
            }

            var interaction = await _interactionPatchService.GetInteractionForCustomerAsync(customerGuid, interactionGuid);

            if (interaction == null)
            {
                return(_httpResponseMessageHelper.NoContent(interactionGuid));
            }

            var updatedInteraction = await _interactionPatchService.UpdateAsync(interaction, interactionPatchRequest);

            if (updatedInteraction != null)
            {
                await _interactionPatchService.SendToServiceBusQueueAsync(updatedInteraction, customerGuid, ApimURL);
            }

            return(updatedInteraction == null?
                   _httpResponseMessageHelper.BadRequest(interactionGuid) :
                       _httpResponseMessageHelper.Ok(_jsonHelper.SerializeObjectAndRenameIdProperty(updatedInteraction, "id", "InteractionId")));
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Customers/{customerId}/DiversityDetails")] HttpRequestMessage req, ILogger log, string customerId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPostDiversityHttpTriggerService postDiversityService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            Models.Diversity diversityRequest;

            try
            {
                diversityRequest = await httpRequestMessageHelper.GetDiversityFromRequest <Models.Diversity>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (diversityRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            diversityRequest.SetIds(customerGuid, touchpointId);

            var errors = validate.ValidateResource(diversityRequest);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesDiversityDetailsExist = postDiversityService.DoesDiversityDetailsExistForCustomer(customerGuid);

            if (doesDiversityDetailsExist)
            {
                return(HttpResponseMessageHelper.Conflict());
            }

            var diversity = await postDiversityService.CreateAsync(diversityRequest);

            return(diversity == null
                ? HttpResponseMessageHelper.BadRequest(customerGuid)
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(diversity)));
        }
示例#12
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "AdviserDetails/{adviserDetailId}")] HttpRequestMessage req, ILogger log, string adviserDetailId,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPatchAdviserDetailHttpTriggerService adviserDetailsPatchService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Patch Adviser Detail C# HTTP trigger function processed a request. " + touchpointId);

            if (!Guid.TryParse(adviserDetailId, out var adviserDetailGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(adviserDetailGuid));
            }

            Models.AdviserDetailPatch adviserDetailPatchRequest;

            try
            {
                adviserDetailPatchRequest = await httpRequestMessageHelper.GetAdviserDetailFromRequest <Models.AdviserDetailPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (adviserDetailPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            adviserDetailPatchRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(adviserDetailPatchRequest, false);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var adviserDetail = await adviserDetailsPatchService.GetAdviserDetailByIdAsync(adviserDetailGuid);

            if (adviserDetail == null)
            {
                return(HttpResponseMessageHelper.NoContent(adviserDetailGuid));
            }

            var patchedAdviserDetail = adviserDetailsPatchService.PatchResource(adviserDetail, adviserDetailPatchRequest);

            if (patchedAdviserDetail == null)
            {
                return(HttpResponseMessageHelper.NoContent(adviserDetailGuid));
            }

            var updatedAdviserDetail = await adviserDetailsPatchService.UpdateCosmosAsync(patchedAdviserDetail, adviserDetailGuid);

            return(updatedAdviserDetail == null
                ? HttpResponseMessageHelper.BadRequest(adviserDetailGuid)
                : HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedAdviserDetail)));
        }
示例#13
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/Addresses/{addressId}")] HttpRequestMessage req, ILogger log, string customerId, string addressId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPatchAddressHttpTriggerService addressPatchService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Patch Address C# HTTP trigger function  processed a request. By Touchpoint " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(addressId, out var addressGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(addressGuid));
            }

            AddressPatch addressPatchRequest;

            try
            {
                addressPatchRequest = await httpRequestMessageHelper.GetAddressFromRequest <AddressPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (addressPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            addressPatchRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(addressPatchRequest, false);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var addressForCustomer = await addressPatchService.GetAddressForCustomerAsync(customerGuid, addressGuid);

            if (addressForCustomer == null)
            {
                return(HttpResponseMessageHelper.NoContent(addressGuid));
            }

            var patchedAddress = addressPatchService.PatchResource(addressForCustomer, addressPatchRequest);

            if (patchedAddress == null)
            {
                return(HttpResponseMessageHelper.NoContent(addressGuid));
            }

            var updatedAddress = await addressPatchService.UpdateCosmosAsync(patchedAddress, addressGuid);

            if (updatedAddress != null)
            {
                await addressPatchService.SendToServiceBusQueueAsync(updatedAddress, customerGuid, ApimURL);
            }

            return(updatedAddress == null?
                   HttpResponseMessageHelper.BadRequest(addressGuid) :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedAddress)));
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "customers/{customerId}/interactions/{interactionId}/sessions/")] HttpRequestMessage req, ILogger log, string customerId, string interactionId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPostSessionHttpTriggerService sessionPostService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function Post Session processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(interactionId, out var interactionGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(interactionGuid));
            }

            Session sessionRequest;

            try
            {
                sessionRequest = await httpRequestMessageHelper.GetSessionFromRequest <Session>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (sessionRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            sessionRequest.SetIds(customerGuid, interactionGuid, touchpointId);

            var errors = validate.ValidateResource(sessionRequest);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesInteractionExist = resourceHelper.DoesInteractionResourceExistAndBelongToCustomer(interactionGuid, customerGuid);

            if (!doesInteractionExist)
            {
                return(HttpResponseMessageHelper.NoContent(interactionGuid));
            }

            var session = await sessionPostService.CreateAsync(sessionRequest);

            if (session != null)
            {
                await sessionPostService.SendToServiceBusQueueAsync(session, ApimURL);
            }

            return(session == null
                ? HttpResponseMessageHelper.BadRequest(customerGuid)
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(session)));
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/Interactions/{interactionId}/actionplans/{actionplanId}/Outcomes/{OutcomeId}")] HttpRequestMessage req, ILogger log, string customerId, string interactionId, string actionplanId, string OutcomeId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPatchOutcomesHttpTriggerService outcomesPatchService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Patch Action Plan C# HTTP trigger function processed a request. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(interactionId, out var interactionGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(interactionGuid));
            }

            if (!Guid.TryParse(actionplanId, out var actionplanGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(actionplanGuid));
            }

            if (!Guid.TryParse(OutcomeId, out var outcomesGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(outcomesGuid));
            }

            Models.OutcomesPatch outcomesPatchRequest;

            try
            {
                outcomesPatchRequest = await httpRequestMessageHelper.GetOutcomesFromRequest <Models.OutcomesPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (outcomesPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            outcomesPatchRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(outcomesPatchRequest);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesInteractionExist = resourceHelper.DoesInteractionResourceExistAndBelongToCustomer(interactionGuid, customerGuid);

            if (!doesInteractionExist)
            {
                return(HttpResponseMessageHelper.NoContent(interactionGuid));
            }

            var doesActionPlanExist = resourceHelper.DoesActionPlanResourceExistAndBelongToCustomer(actionplanGuid, interactionGuid, customerGuid);

            if (!doesActionPlanExist)
            {
                return(HttpResponseMessageHelper.NoContent(actionplanGuid));
            }

            var outcomeForCustomer = await outcomesPatchService.GetOutcomesForCustomerAsync(customerGuid, interactionGuid, actionplanGuid, outcomesGuid);

            if (outcomeForCustomer == null)
            {
                return(HttpResponseMessageHelper.NoContent(outcomesGuid));
            }

            var patchedOutcome = outcomesPatchService.PatchResource(outcomeForCustomer, outcomesPatchRequest);

            if (patchedOutcome == null)
            {
                return(HttpResponseMessageHelper.NoContent(outcomesGuid));
            }

            var updatedOutcomes = await outcomesPatchService.UpdateCosmosAsync(patchedOutcome, outcomesGuid);

            if (updatedOutcomes != null)
            {
                await outcomesPatchService.SendToServiceBusQueueAsync(updatedOutcomes, customerGuid, ApimURL);
            }

            return(updatedOutcomes == null?
                   HttpResponseMessageHelper.BadRequest(outcomesGuid) :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedOutcomes)));
        }
        public static async Task <HttpResponseMessage> RunAsync([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Customers/")] HttpRequestMessage req, ILogger log,
                                                                [Inject] IResourceHelper resourceHelper,
                                                                [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                                [Inject] IValidate validate,
                                                                [Inject] IPostCustomerHttpTriggerService customerPostService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }


            log.LogInformation("C# HTTP trigger function Post Customer processed a request. By Touchpoint " + touchpointId);

            Models.Customer customerRequest;

            try
            {
                customerRequest = await httpRequestMessageHelper.GetCustomerFromRequest <Models.Customer>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (customerRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            customerRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(customerRequest, true);

            if (errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var customer = await customerPostService.CreateNewCustomerAsync(customerRequest);

            log.LogInformation("Apimurl:  " + ApimURL);

            if (customer != null)
            {
                await customerPostService.SendToServiceBusQueueAsync(customer, ApimURL.ToString());
            }

            return(customer == null
                ? HttpResponseMessageHelper.BadRequest()
                : HttpResponseMessageHelper.Created(JsonHelper.SerializeObject(customer)));
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/Interactions/{interactionId}/Transfers/{transferId}")] HttpRequestMessage req, ILogger log, string customerId, string interactionId, string transferId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPatchTransferHttpTriggerService transferPatchService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(HttpResponseMessageHelper.BadRequest());
            }

            var ApimURL = httpRequestMessageHelper.GetApimURL(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Patch Transfer C# HTTP trigger function processed a request. By Touchpoint. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(interactionId, out var interactionGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(interactionGuid));
            }

            if (!Guid.TryParse(transferId, out var transferGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(transferGuid));
            }

            Models.TransferPatch transferPatchRequest;

            try
            {
                transferPatchRequest = await httpRequestMessageHelper.GetTransferFromRequest <Models.TransferPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (transferPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            transferPatchRequest.LastModifiedTouchpointId = touchpointId;

            var errors = validate.ValidateResource(transferPatchRequest, false);

            if (errors != null && errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesInteractionExist = resourceHelper.DoesInteractionResourceExistAndBelongToCustomer(interactionGuid, customerGuid);

            if (!doesInteractionExist)
            {
                return(HttpResponseMessageHelper.NoContent(interactionGuid));
            }

            var transfer = await transferPatchService.GetTransferForCustomerAsync(customerGuid, transferGuid);

            if (transfer == null)
            {
                return(HttpResponseMessageHelper.NoContent(transferGuid));
            }

            var updatedTransfer = await transferPatchService.UpdateAsync(transfer, transferPatchRequest);

            if (updatedTransfer != null)
            {
                await transferPatchService.SendToServiceBusQueueAsync(transfer, customerGuid, ApimURL);
            }

            return(updatedTransfer == null?
                   HttpResponseMessageHelper.BadRequest(transferGuid) :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedTransfer)));
        }
        public async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/Subscriptions/{subscriptionId}")] HttpRequest req, ILogger log, string customerId, string subscriptionId)
        {
            var touchpointId = _httpRequestMessageHelper.GetDssTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header");
                return(_httpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function processed a request. By Touchpoint " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(subscriptionId, out var subscriptionsGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(subscriptionsGuid));
            }

            SubscriptionsPatch subscriptionsPatchRequest;

            try
            {
                subscriptionsPatchRequest = await _httpRequestMessageHelper.GetResourceFromRequest <SubscriptionsPatch>(req);
            }
            catch (JsonSerializationException ex)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (subscriptionsPatchRequest == null)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(req));
            }

            subscriptionsPatchRequest.LastModifiedBy = touchpointId;

            var errors = _validate.ValidateResource(subscriptionsPatchRequest);

            if (errors != null && errors.Any())
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await _resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(_httpResponseMessageHelper.NoContent(customerGuid));
            }

            var subscriptions = await _subscriptionsPatchService.GetSubscriptionsForCustomerAsync(customerGuid, subscriptionsGuid);

            if (subscriptions == null)
            {
                return(_httpResponseMessageHelper.NoContent(subscriptionsGuid));
            }

            var updatedSubscriptions = await _subscriptionsPatchService.UpdateAsync(subscriptions, subscriptionsPatchRequest);

            return(updatedSubscriptions == null?
                   _httpResponseMessageHelper.BadRequest(subscriptionsGuid) :
                       _httpResponseMessageHelper.Ok(JsonHelper.SerializeObject(updatedSubscriptions)));
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "patch", Route = "Customers/{customerId}/DiversityDetails/{diversityId}")] HttpRequestMessage req, ILogger log, string customerId, string diversityId,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] IValidate validate,
                                                           [Inject] IPatchDiversityHttpTriggerService patchDiversityService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function Patch Customer processed a request. By Touchpoint " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(diversityId, out var diversityGuid))
            {
                return(HttpResponseMessageHelper.BadRequest(diversityGuid));
            }

            Models.DiversityPatch diversityPatchRequest;

            try
            {
                diversityPatchRequest = await httpRequestMessageHelper.GetDiversityFromRequest <Models.DiversityPatch>(req);
            }
            catch (JsonException ex)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (diversityPatchRequest == null)
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(req));
            }

            diversityPatchRequest.LastModifiedBy = touchpointId;

            // validate the request
            var errors = validate.ValidateResource(diversityPatchRequest);

            if (errors.Any())
            {
                return(HttpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(HttpResponseMessageHelper.Forbidden(customerGuid));
            }

            var diversity = await patchDiversityService.GetDiversityByIdAsync(customerGuid, diversityGuid);

            if (diversity == null)
            {
                return(HttpResponseMessageHelper.NoContent(customerGuid));
            }

            var updatedDiversity = await patchDiversityService.UpdateDiversityAsync(diversity, diversityPatchRequest);

            return(updatedDiversity == null?
                   HttpResponseMessageHelper.BadRequest(customerGuid) :
                       HttpResponseMessageHelper.Ok());
        }
        public async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Customers/{customerId}/Interactions/{interactionId}/Transfers/")] HttpRequest req, ILogger log, string customerId, string interactionId)
        {
            var touchpointId = _httpRequestMessageHelper.GetDssTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'TouchpointId' in request header.");
                return(_httpResponseMessageHelper.BadRequest());
            }

            var ApimURL = _httpRequestMessageHelper.GetDssApimUrl(req);

            if (string.IsNullOrEmpty(ApimURL))
            {
                log.LogInformation("Unable to locate 'apimurl' in request header");
                return(_httpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("Post Transfer C# HTTP trigger function processed a request. By Touchpoint. " + touchpointId);

            if (!Guid.TryParse(customerId, out var customerGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(customerGuid));
            }

            if (!Guid.TryParse(interactionId, out var interactionGuid))
            {
                return(_httpResponseMessageHelper.BadRequest(interactionGuid));
            }

            Models.Transfer transferRequest;

            try
            {
                transferRequest = await _httpRequestMessageHelper.GetResourceFromRequest <Models.Transfer>(req);
            }
            catch (JsonException ex)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(ex));
            }

            if (transferRequest == null)
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(req));
            }

            transferRequest.SetIds(customerGuid, interactionGuid, touchpointId);

            var errors = _validate.ValidateResource(transferRequest, true);

            if (errors != null && errors.Any())
            {
                return(_httpResponseMessageHelper.UnprocessableEntity(errors));
            }

            var doesCustomerExist = await _resourceHelper.DoesCustomerExist(customerGuid);

            if (!doesCustomerExist)
            {
                return(_httpResponseMessageHelper.NoContent(customerGuid));
            }

            var isCustomerReadOnly = await _resourceHelper.IsCustomerReadOnly(customerGuid);

            if (isCustomerReadOnly)
            {
                return(_httpResponseMessageHelper.Forbidden(customerGuid));
            }

            var doesInteractionExist = _resourceHelper.DoesInteractionResourceExistAndBelongToCustomer(interactionGuid, customerGuid);

            if (!doesInteractionExist)
            {
                return(_httpResponseMessageHelper.NoContent(interactionGuid));
            }

            var transfer = await _transferPostService.CreateAsync(transferRequest);

            if (transfer != null)
            {
                await _transferPostService.SendToServiceBusQueueAsync(transfer, ApimURL);
            }

            return(transfer == null?
                   _httpResponseMessageHelper.BadRequest(customerGuid) :
                       _httpResponseMessageHelper.Created(_jsonHelper.SerializeObjectAndRenameIdProperty(transfer, "id", "TransferId")));
        }