Пример #1
0
        public async Task <List <Models.WebChat> > GetWebChatsForCustomerAsync(Guid customerId, Guid interactionId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

            var webchatsQuery = client.CreateDocumentQuery <Models.WebChat>(collectionUri)
                                .Where(so => so.CustomerId == customerId &&
                                       so.InteractionId == interactionId).AsDocumentQuery();

            var webchats = new List <Models.WebChat>();

            while (webchatsQuery.HasMoreResults)
            {
                var response = await webchatsQuery.ExecuteNextAsync <Models.WebChat>();

                webchats.AddRange(response);
            }

            return(webchats.Any() ? webchats : null);
        }
        public async Task <List <Models.Region> > GetRegionsForPathAsync(string path)
        {
            var client = DocumentDBClient.CreateDocumentClient();

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

            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var regionsQuery = client.CreateDocumentQuery <Models.Region>(collectionUri, new FeedOptions {
                EnableCrossPartitionQuery = true
            })
                               .Where(so => so.Path == path)
                               .AsDocumentQuery();

            var regions = new List <Models.Region>();

            while (regionsQuery.HasMoreResults)
            {
                var response = await regionsQuery.ExecuteNextAsync <Models.Region>();

                regions.AddRange(response);
            }

            return(regions.Any() ? regions : null);
        }
        public async Task <List <Models.Subscriptions> > SearchAllSubscriptions()
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

            var queryCust = client.CreateDocumentQuery <Models.Subscriptions>(collectionUri)
                            .AsDocumentQuery();

            var subscriptions = new List <Models.Subscriptions>();

            while (queryCust.HasMoreResults)
            {
                var response = await queryCust.ExecuteNextAsync <Models.Subscriptions>();

                subscriptions.AddRange(response);
            }

            return(subscriptions.Any() ? subscriptions : null);
        }
        public async Task <List <Models.Subscriptions> > GetSubscriptionsForTouchpointAsync(Guid?customerId, string touchpointId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var subscriptionsForTouchpointQuery = client
                                                  ?.CreateDocumentQuery <Models.Subscriptions>(collectionUri)
                                                  .Where(x => x.CustomerId == customerId && x.TouchPointId == touchpointId)
                                                  .AsDocumentQuery();

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

            var subscriptions = new List <Models.Subscriptions>();

            while (subscriptionsForTouchpointQuery.HasMoreResults)
            {
                var response = await subscriptionsForTouchpointQuery.ExecuteNextAsync <Models.Subscriptions>();

                subscriptions.AddRange(response);
            }

            return(subscriptions.Any() ? subscriptions : null);
        }
        public async Task <Models.Region> GetRegionByIdAsync(Guid documentId)
        {
            var client = DocumentDBClient.CreateDocumentClient();

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

            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var regionForCustomerQuery = client
                                         ?.CreateDocumentQuery <Models.Region>(collectionUri, new FeedOptions {
                MaxItemCount = 1, EnableCrossPartitionQuery = true
            })
                                         .Where(x => x.DocumentId == documentId)
                                         .AsDocumentQuery();

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

            var Regions = await regionForCustomerQuery.ExecuteNextAsync <Models.Region>();

            return(Regions?.FirstOrDefault());
        }
        public async Task <Models.Region> GetRegionForPathAsync(string path, Constants.PageRegions pageRegion)
        {
            var client = DocumentDBClient.CreateDocumentClient();

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

            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var regionForCustomerQuery = client
                                         ?.CreateDocumentQuery <Models.Region>(collectionUri, new FeedOptions {
                MaxItemCount = 1, EnableCrossPartitionQuery = true
            })
                                         .Where(x => x.Path == path && x.PageRegion == pageRegion)
                                         .AsDocumentQuery();

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

            var Regions = await regionForCustomerQuery.ExecuteNextAsync <Models.Region>();

            return(Regions?.FirstOrDefault());
        }
        public async Task <List <Models.ActionPlan> > GetActionPlansForCustomerAsync(Guid customerId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

            var actionPlansQuery = client.CreateDocumentQuery <Models.ActionPlan>(collectionUri)
                                   .Where(so => so.CustomerId == customerId).AsDocumentQuery();

            var actionPlans = new List <Models.ActionPlan>();

            while (actionPlansQuery.HasMoreResults)
            {
                var response = await actionPlansQuery.ExecuteNextAsync <Models.ActionPlan>();

                actionPlans.AddRange(response);
            }

            return(actionPlans.Any() ? actionPlans : null);
        }
Пример #8
0
        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 <ResourceResponse <Document> > CreateSubscriptionsAsync(Models.Subscriptions subscriptions)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

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

            return(response);
        }
        public async Task <ResourceResponse <Document> > CreateAdviserDetailAsync(Models.AdviserDetail adviserDetail)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

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

            return(response);
        }
Пример #11
0
        public async Task <ResourceResponse <Document> > CreateCustomerAsync(Models.Customer customer)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

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

            return(response);
        }
        public async Task <ResourceResponse <Document> > CreateContactDetailsAsync(ContactDetails contactDetails)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

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

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

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

            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

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

            return(response);
        }
Пример #14
0
        public bool DoesDiversityDetailsExistForCustomer(Guid customerId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

            var diversityDetailsForCustomerQuery = client.CreateDocumentQuery <Models.Diversity>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            });

            return(diversityDetailsForCustomerQuery.Where(x => x.CustomerId == customerId).AsEnumerable().Any());
        }
        public async Task <bool> DoesContactDetailsWithEmailExistsForAnotherCustomer(string email, Guid CustomerId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();
            var client        = DocumentDBClient.CreateDocumentClient();
            var contactDetailsForEmailQuery = client
                                              ?.CreateDocumentQuery <ContactDetails>(collectionUri, new FeedOptions {
                MaxItemCount = 1, EnableCrossPartitionQuery = true
            })
                                              .Where(x => x.EmailAddress == email && x.CustomerId != CustomerId)
                                              .AsDocumentQuery();

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

            var contactDetails = await contactDetailsForEmailQuery.ExecuteNextAsync <ContactDetails>();

            return(contactDetails.Any());
        }
        public async Task <IList <ContactDetails> > GetContactsByEmail(string emailAddressToCheck)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();
            var client        = DocumentDBClient.CreateDocumentClient();
            var contactDetailsForEmailQuery = client
                                              ?.CreateDocumentQuery <ContactDetails>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                              .Where(x => x.EmailAddress == emailAddressToCheck)
                                              .AsDocumentQuery();

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

            var contactDetails = await contactDetailsForEmailQuery.ExecuteNextAsync <ContactDetails>();

            return(contactDetails.ToList());
        }
        public async Task <string> GetActionPlanForCustomerToUpdateAsync(Guid customerId, Guid actionPlanId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var actionPlanForCustomerQuery = client
                                             ?.CreateDocumentQuery <Models.ActionPlan>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                             .Where(x => x.CustomerId == customerId && x.ActionPlanId == actionPlanId)
                                             .AsDocumentQuery();

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

            var actionPlans = await actionPlanForCustomerQuery.ExecuteNextAsync();

            return(actionPlans?.FirstOrDefault()?.ToString());
        }
        public async Task <Models.Address> GetAddressForCustomerAsync(Guid customerId, Guid addressId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var addressForCustomerQuery = client
                                          ?.CreateDocumentQuery <Models.Address>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                          .Where(x => x.CustomerId == customerId && x.AddressId == addressId)
                                          .AsDocumentQuery();

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

            var addressess = await addressForCustomerQuery.ExecuteNextAsync <Models.Address>();

            return(addressess?.FirstOrDefault());
        }
Пример #19
0
        public async Task <Session> GetSessionForCustomerAsync(Guid customerId, Guid sessionId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var sessionForCustomerQuery = client
                                          ?.CreateDocumentQuery <Session>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                          .Where(x => x.CustomerId == customerId && x.SessionId == sessionId)
                                          .AsDocumentQuery();

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

            var sessions = await sessionForCustomerQuery.ExecuteNextAsync <Session>();

            return(sessions?.FirstOrDefault());
        }
        public async Task <Models.Transfer> GetTransferForCustomerAsync(Guid customerId, Guid transferId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var transferForCustomerQuery = client
                                           ?.CreateDocumentQuery <Models.Transfer>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                           .Where(x => x.CustomerId == customerId && x.TransferId == transferId)
                                           .AsDocumentQuery();

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

            var transfers = await transferForCustomerQuery.ExecuteNextAsync <Models.Transfer>();

            return(transfers?.FirstOrDefault());
        }
        public async Task <Guid?> DoesSubscriptionExist(Guid customerId, string touchpointId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var subscriptionsByIdQuery = client?.CreateDocumentQuery <Models.Subscriptions>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                         .Where(x => x.CustomerId == customerId &&
                                                x.TouchPointId == touchpointId &&
                                                x.Subscribe == true).AsDocumentQuery();;

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

            var subscription = await subscriptionsByIdQuery.ExecuteNextAsync <Models.Subscriptions>();

            return(subscription?.FirstOrDefault()?.SubscriptionId);
        }
        public async Task <string> GetAdviserDetailsByIdToUpdateAsync(Guid adviserDetailId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var adviserdetailForCustomerQuery = client
                                                ?.CreateDocumentQuery <Models.AdviserDetail>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                                .Where(x => x.AdviserDetailId == adviserDetailId)
                                                .AsDocumentQuery();

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

            var adviserDetail = await adviserdetailForCustomerQuery.ExecuteNextAsync();

            return(adviserDetail?.FirstOrDefault()?.ToString());
        }
        public async Task <Models.Subscriptions> GetSubscriptionsForCustomerAsync(Guid?customerId, Guid?subscriptionId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var subscriptionsByIdQuery = client
                                         ?.CreateDocumentQuery <Models.Subscriptions>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                         .Where(x => x.SubscriptionId == subscriptionId && x.CustomerId == customerId)
                                         .AsDocumentQuery();

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

            var customer = await subscriptionsByIdQuery.ExecuteNextAsync <Models.Subscriptions>();

            return(customer?.FirstOrDefault());
        }
        public async Task <ContactDetails> GetContactDetailForCustomerAsync(Guid customerId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var contactDetailsForCustomerQuery = client
                                                 ?.CreateDocumentQuery <ContactDetails>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                                 .Where(x => x.CustomerId == customerId)
                                                 .AsDocumentQuery();

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

            var contactDetails = await contactDetailsForCustomerQuery.ExecuteNextAsync <ContactDetails>();

            return(contactDetails?.FirstOrDefault());
        }
Пример #25
0
        public async Task <Models.Diversity> GetDiversityDetailForCustomerAsync(Guid customerId, Guid diversityId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var diversityDetailQuery = client
                                       ?.CreateDocumentQuery <Models.Diversity>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                       .Where(x => x.CustomerId == customerId &&
                                              x.DiversityId == diversityId)
                                       .AsDocumentQuery();

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

            var diversityDetails = await diversityDetailQuery.ExecuteNextAsync <Models.Diversity>();

            return(diversityDetails?.FirstOrDefault());
        }
Пример #26
0
        public async Task <List <Models.Customer> > GetAllCustomer()
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

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

            var queryCust = client.CreateDocumentQuery <Models.Customer>(collectionUri).AsDocumentQuery();

            var customers = new List <Models.Customer>();

            while (queryCust.HasMoreResults)
            {
                var response = await queryCust.ExecuteNextAsync <Models.Customer>();

                customers.AddRange(response);
            }

            return(customers.Any() ? customers: null);
        }
Пример #27
0
        public async Task <Models.WebChat> GetWebChatForCustomerAsync(Guid customerId, Guid interactionId, Guid webchatId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var webchatForCustomerQuery = client
                                          ?.CreateDocumentQuery <Models.WebChat>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                          .Where(x => x.CustomerId == customerId &&
                                                 x.InteractionId == interactionId &&
                                                 x.WebChatId == webchatId)
                                          .AsDocumentQuery();

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

            var webchats = await webchatForCustomerQuery.ExecuteNextAsync <Models.WebChat>();

            return(webchats?.FirstOrDefault());
        }
        public async Task <Models.Outcomes> GetOutcomesForCustomerAsync(Guid customerId, Guid interactionsId, Guid actionplanId, Guid outcomeId)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            var outcomesForCustomerQuery = client
                                           ?.CreateDocumentQuery <Models.Outcomes>(collectionUri, new FeedOptions {
                MaxItemCount = 1
            })
                                           .Where(x => x.CustomerId == customerId &&
                                                  x.ActionPlanId == actionplanId &&
                                                  x.OutcomeId == outcomeId)
                                           .AsDocumentQuery();

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

            var outcomes = await outcomesForCustomerQuery.ExecuteNextAsync <Models.Outcomes>();

            return(outcomes?.FirstOrDefault());
        }