Beispiel #1
0
        public async Task <bool> DoesCustomerResourceExist(Guid customerId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(customerId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            try
            {
                var response = await client.ReadDocumentAsync(documentUri);

                if (response.Resource != null)
                {
                    return(true);
                }
            }
            catch (DocumentClientException)
            {
                return(false);
            }

            return(false);
        }
Beispiel #2
0
        public async Task <Models.Customer> GetCustomerByIdAsync(Guid customerId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(customerId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            try
            {
                var response = await client.ReadDocumentAsync(documentUri);

                if (response.Resource != null)
                {
                    return((dynamic)response.Resource);
                }
            }
            catch (DocumentClientException)
            {
                return(null);
            }

            return(null);
        }
Beispiel #3
0
        public async Task <string> GetCustomerByIdForUpdateAsync(Guid customerId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(customerId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            try
            {
                var response = await client.ReadDocumentAsync(documentUri);

                if (response.Resource != null)
                {
                    return(response.Resource.ToString());
                }
            }
            catch (DocumentClientException)
            {
                return(null);
            }

            return(null);
        }
Beispiel #4
0
        public async Task <ResourceResponse <Document> > UpdateDiversityDetailAsync(Models.Diversity diversity)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(diversity.DiversityId.GetValueOrDefault());

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReplaceDocumentAsync(documentUri, diversity);

            return(response);
        }
Beispiel #5
0
        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> > UpdateTransferAsync(Models.Transfer transfer)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(transfer.TransferId.GetValueOrDefault());

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReplaceDocumentAsync(documentUri, transfer);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateRegionAsync(Region region)
        {
            var client = DocumentDBClient.CreateDocumentClient();

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

            var documentUri = DocumentDBHelper.CreateDocumentUri(region.DocumentId.Value);

            var response = await client.ReplaceDocumentAsync(documentUri, region);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateContactDetailsAsync(ContactDetails contactDetails)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(contactDetails.ContactId.GetValueOrDefault());

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReplaceDocumentAsync(documentUri, contactDetails);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateSubscriptionsAsync(Models.Subscriptions subscriptions)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(subscriptions.SubscriptionId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReplaceDocumentAsync(documentUri, subscriptions);

            return(response);
        }
        public async Task <bool> DeleteAsync(Guid outcomeId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(outcomeId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.DeleteDocumentAsync(documentUri);

            return(response.StatusCode == HttpStatusCode.OK);
        }
        public async Task <ResourceResponse <Document> > GetAddressAsync(Guid addressId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(addressId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReadDocumentAsync(documentUri);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateInteractionAsync(Models.Interaction interaction)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(interaction.InteractionId.GetValueOrDefault());

            var client = DocumentDBClient.CreateDocumentClient();

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

            var response = await client.ReplaceDocumentAsync(documentUri, interaction);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateActionPlanAsync(string actionPlanJson, Guid actionPlanId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(actionPlanId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var actionPlanDocumentJObject = JObject.Parse(actionPlanJson);

            var response = await client.ReplaceDocumentAsync(documentUri, actionPlanDocumentJObject);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateAdviserDetailAsync(string adviserDetailJson, Guid adviserDetailId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(adviserDetailId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var adviserDetailDocumentJObject = JObject.Parse(adviserDetailJson);

            var response = await client.ReplaceDocumentAsync(documentUri, adviserDetailDocumentJObject);

            return(response);
        }
        public async Task <ResourceResponse <Document> > DeleteRegionAsync(Guid documentId)
        {
            var client = DocumentDBClient.CreateDocumentClient();

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

            var documentUri      = DocumentDBHelper.CreateDocumentUri(documentId);
            var existingDocument = await GetRegionByIdAsync(documentId).ConfigureAwait(false);

            var partitionKey = new PartitionKey(existingDocument?.Path);

            var response = await client.DeleteDocumentAsync(documentUri, new RequestOptions()
            {
                PartitionKey = partitionKey
            });

            return(response);
        }
Beispiel #16
0
        public async Task <ResourceResponse <Document> > UpdateCustomerAsync(string customerJson, Guid customerId)
        {
            if (string.IsNullOrEmpty(customerJson))
            {
                return(null);
            }

            var documentUri = DocumentDBHelper.CreateDocumentUri(customerId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var customerDocumentObject = JObject.Parse(customerJson);

            var response = await client.ReplaceDocumentAsync(documentUri, customerDocumentObject);

            return(response);
        }
Beispiel #17
0
        public async Task <ResourceResponse <Document> > UpdateGoalAsync(string goalJson, Guid goalId)
        {
            if (string.IsNullOrEmpty(goalJson))
            {
                return(null);
            }

            var documentUri = DocumentDBHelper.CreateDocumentUri(goalId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var goalDocumentJObject = JObject.Parse(goalJson);

            var response = await client.ReplaceDocumentAsync(documentUri, goalDocumentJObject);

            return(response);
        }
        public async Task <ResourceResponse <Document> > UpdateOutcomesAsync(string outcomeJson, Guid outcomeId)
        {
            if (string.IsNullOrEmpty(outcomeJson))
            {
                return(null);
            }

            var documentUri = DocumentDBHelper.CreateDocumentUri(outcomeId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var outcomeDocumentJObject = JObject.Parse(outcomeJson);

            var response = await client.ReplaceDocumentAsync(documentUri, outcomeDocumentJObject);

            return(response);
        }
        public async Task <Models.AdviserDetail> GetAdviserDetailByIdAsync(Guid adviserDetailId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(adviserDetailId);

            var client = DocumentDBClient.CreateDocumentClient();

            try
            {
                var response = await client.ReadDocumentAsync(documentUri);

                if (response.Resource != null)
                {
                    return((dynamic)response.Resource);
                }
            }
            catch (DocumentClientException)
            {
                return(null);
            }

            return(null);
        }
        public async Task <ResourceResponse <Document> > UpdateAddressAsync(string addressJson, Guid addressId)
        {
            if (string.IsNullOrEmpty(addressJson))
            {
                return(null);
            }

            var documentUri = DocumentDBHelper.CreateDocumentUri(addressId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            var addressDocumentJObject = JObject.Parse(addressJson);

            var response = await client.ReplaceDocumentAsync(documentUri, addressDocumentJObject);

            return(response);
        }
Beispiel #21
0
        public async Task <bool> DoesCustomerHaveATerminationDate(Guid customerId)
        {
            var documentUri = DocumentDBHelper.CreateDocumentUri(customerId);

            var client = DocumentDBClient.CreateDocumentClient();

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

            try
            {
                var response = await client.ReadDocumentAsync(documentUri);

                var dateOfTermination = response.Resource?.GetPropertyValue <DateTime?>("DateOfTermination");

                return(dateOfTermination.HasValue);
            }
            catch (DocumentClientException)
            {
                return(false);
            }
        }