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 <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 <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 <List <Models.Subscriptions> > GetSubscriptionsByCustomerIdAsync(Guid?customerId) { var collectionUri = DocumentDBHelper.CreateSubscriptionDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); var query = client ?.CreateDocumentQuery <Models.Subscriptions>(collectionUri) .Where(x => x.CustomerId == customerId && x.Subscribe) .AsDocumentQuery(); if (query == null) { return(null); } var subscriptions = new List <Models.Subscriptions>(); while (query.HasMoreResults) { var results = await query.ExecuteNextAsync <Models.Subscriptions>(); subscriptions.AddRange(results); } return(subscriptions.Any() ? subscriptions : null); }
public bool DoesInteractionResourceExistAndBelongToCustomer(Guid interactionId, Guid customerId) { var collectionUri = DocumentDBHelper.CreateInteractionDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(false); } try { var query = client.CreateDocumentQuery <long>(collectionUri, new SqlQuerySpec() { QueryText = "SELECT VALUE COUNT(1) FROM interactions i " + "WHERE i.id = @interactionId " + "AND i.CustomerId = @customerId", Parameters = new SqlParameterCollection() { new SqlParameter("@interactionId", interactionId), new SqlParameter("@customerId", customerId) } }).AsEnumerable().FirstOrDefault(); return(Convert.ToBoolean(Convert.ToInt16(query))); } catch (DocumentQueryException) { return(false); } }
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); }
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 <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); }
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 <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); }
public async Task <List <dynamic> > GetSessionsWithVenuePostCodeAsync() { var collectionUri = DocumentDBHelper.CreateSessionDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); var sessionsWithVenuePostcodesQuery = client ?.CreateDocumentQuery <Session>(collectionUri, new FeedOptions { MaxItemCount = 1000 }) .Where(x => x.VenuePostCode != null) .AsDocumentQuery(); if (sessionsWithVenuePostcodesQuery == null) { return(null); } var sessions = new List <dynamic>(); while (sessionsWithVenuePostcodesQuery.HasMoreResults) { var response = await sessionsWithVenuePostcodesQuery.ExecuteNextAsync(); sessions.AddRange(response); } return(sessions.Any() ? sessions : null); }
public async Task <List <dynamic> > GetAddressWithPostCodeAsync() { var collectionUri = DocumentDBHelper.CreateAddressDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); var addressesWithVenuePostcodesQuery = client ?.CreateDocumentQuery <Address>(collectionUri, new FeedOptions { MaxItemCount = 1000 }) .Where(x => x.PostCode != null && x.Latitude == null && x.Longitude == null) .AsDocumentQuery(); if (addressesWithVenuePostcodesQuery == null) { return(null); } var addresses = new List <dynamic>(); while (addressesWithVenuePostcodesQuery.HasMoreResults) { var response = await addressesWithVenuePostcodesQuery.ExecuteNextAsync(); addresses.AddRange(response); } return(addresses.Any() ? addresses : null); }
public async Task <bool> DoesCustomerResourceExist(Guid customerId) { var documentUri = DocumentDBHelper.CreateCustomerDocumentUri(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); }
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 <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> > 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); }
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> > 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> > 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); }
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> > 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> > 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); }
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> > CreateSubscriptionsAsync(Models.Subscriptions subscriptions) { var collectionUri = DocumentDBHelper.CreateSubscriptionDocumentCollectionUri(); var client = DocumentDBClient.CreateDocumentClient(); if (client == null) { return(null); } var response = await client.CreateDocumentAsync(collectionUri, 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> > 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> > 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> > 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> > 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 <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); }