public async Task DeleteClaimsByUser( Guid siteId, Guid userId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (siteId == Guid.Empty) { throw new ArgumentException("SiteId must be provided"); } if (userId == Guid.Empty) { throw new ArgumentException("UserId must be provided"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); var all = await claimQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var filtered = all.Where( x => x.UserId == userId && x.SiteId == siteId ); foreach (var item in filtered) { await claimCommands.DeleteAsync( projectId, item.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
public async Task DeleteUserLocationsByUser( Guid siteId, Guid userId, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (userId == Guid.Empty) { throw new ArgumentException("userId must not be empty guid"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); var all = await locationQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var filtered = all.Where(x => x.UserId == userId); foreach (var loc in filtered) { await locationCommands.DeleteAsync( projectId, loc.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
public async Task DeleteUserRoles( Guid siteId, Guid userId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (userId == Guid.Empty) { throw new ArgumentException("userId must be provided"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); var all = await userRoleQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var filtered = all.Where( x => x.UserId == userId ); foreach (var item in filtered) { var key = item.UserId.ToString() + "~" + item.RoleId.ToString(); await roleCommands.DeleteAsync( projectId, key, cancellationToken).ConfigureAwait(false); } }
public async Task <IEnumerable <PushDeviceSubscription> > GetAllSubscriptions( string tenantId, CancellationToken cancellationToken = default(CancellationToken) ) { var all = await _queries.GetAllAsync(_NoDbProjectId).ConfigureAwait(false); return(all.Where(x => x.TenantId == tenantId)); }
public async Task <int> GetLanguageCount(CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var all = await langQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); return(all.ToList().Count); }
// need custom NoDb logic for option to lookup across projects public async Task <ISiteSettings> Fetch( string hostName, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var projectId = "default"; var allHosts = await hostQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var host = allHosts.Where( x => x.HostName.Equals(hostName) ).SingleOrDefault() ; if (host == null) { var allSites = await queries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var query = from s in allSites .Take(1) orderby s.CreatedUtc ascending select s; return(query.SingleOrDefault()); } return(await queries.FetchAsync( projectId, host.SiteId.ToString(), cancellationToken).ConfigureAwait(false)); }
public IActionResult AddEventTest() { var eventCount = _eventQueries.GetAllAsync("BibleBrowserTest").Result.Count() + 1; var e = new Event($"Test Event {eventCount.ToString()}", new EventRelationship.Absolute(new ApproximateDateTime())); _eventCommands.CreateAsync("BibleBrowserTest", e.Id.ToString(), e); var events = _eventQueries.GetAllAsync("BibleBrowserTest").Result; return(View(events)); }
public async Task <int> GetGeoZoneCount( Guid countryId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var all = await stateQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); return(all.Where( g => g.CountryId == countryId).ToList().Count); }
public async Task <IEnumerable <Scope> > FindScopesAsync(IEnumerable <string> scopeNames) { if (scopeNames != null && scopeNames.Any()) { //TODO: cache var allScopes = await _queries.GetAllAsync(_siteId).ConfigureAwait(false); var scopes = allScopes.Where(x => scopeNames.Contains(x.Name)); return(scopes); } return(new List <Scope>()); }
private async Task <IEnumerable <Movie> > GetAllMovies() { IEnumerable <Movie> movies; if (_cache.TryGetValue(moviesCacheKey, out movies)) { return(movies); } movies = await _movieQueries.GetAllAsync(projectId).ConfigureAwait(false); _cache.Set(moviesCacheKey, movies); return(movies); }
public async Task <List <Post> > GetAllPosts( string blogId, CancellationToken cancellationToken = default(CancellationToken) ) { //TODO: caching //if (HttpRuntime.Cache["posts"] == null) var l = await query.GetAllAsync(blogId, cancellationToken).ConfigureAwait(false); var list = l.ToList(); //if (list.Count > 0) //{ // list.Sort((p1, p2) => p2.PubDate.CompareTo(p1.PubDate)); // //HttpRuntime.Cache.Insert("posts", list); //} return(list); //if (HttpRuntime.Cache["posts"] != null) //{ // return (List<Post>)HttpRuntime.Cache["posts"]; //} //return new List<Post>(); }
public async Task DeleteTokensByProvider( Guid siteId, Guid userId, string loginProvider, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); var projectId = siteId.ToString(); var all = await _tokenQueries.GetAllAsync(projectId); var matching = all.Where(x => x.SiteId == siteId && x.UserId == userId && x.LoginProvider == loginProvider); foreach (var t in matching) { var key = t.UserId.ToString() + "~" + t.SiteId.ToString() + "~" + t.LoginProvider + "~" + t.Name; await _tokenCommands.DeleteAsync( projectId, key, cancellationToken).ConfigureAwait(false); } }
public async Task DeleteUsersBySite( Guid siteId, CancellationToken cancellationToken = default(CancellationToken)) { var projectId = siteId.ToString(); await DeleteLoginsBySite(siteId); await DeleteClaimsBySite(siteId); await DeleteUserRolesBySite(siteId); await DeleteTokensBySite(siteId); var all = await userQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var users = all.ToList().AsQueryable(); var query = from x in users.Where(x => x.SiteId == siteId) select x; foreach (var u in query) { await userCommands.DeleteAsync( projectId, u.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
public async Task DeleteGeoZonesByCountry( Guid countryId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (countryId == Guid.Empty) { throw new ArgumentException("countryId must be a non-empty guid"); } await EnsureProjectId().ConfigureAwait(false); var allStates = await stateQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var states = allStates.ToList().AsQueryable(); var query = from l in states where l.CountryId == countryId select l; foreach (var s in query) { await stateCommands.DeleteAsync( projectId, s.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
private async Task <IEnumerable <DeviceFlowCodes> > GetAllInternalAsync(string siteId) { //TODO: cache var all = await _queries.GetAllAsync(siteId).ConfigureAwait(false); return(all); }
private async Task <IEnumerable <PersistedGrant> > GetAllAsync() { //TODO: cache var all = await _queries.GetAllAsync(_siteId).ConfigureAwait(false); return(all); }
public async Task DeleteHostsBySite( Guid siteId, CancellationToken cancellationToken = default(CancellationToken)) { if (siteId == Guid.Empty) { throw new ArgumentException("siteId must not be empty guid"); } ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var allHosts = await hostQueries.GetAllAsync( projectId, cancellationToken).ConfigureAwait(false); var query = from x in allHosts.Where(x => x.SiteId == siteId) select x; foreach (var h in query) { await hostCommands.DeleteAsync( projectId, h.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
private async Task <List <ClientClaim> > GetAllClientClaims(string siteId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); //TODO: cache var all = await _claimQueries.GetAllAsync(siteId, cancellationToken).ConfigureAwait(false); return(all.ToList()); }
public async Task <ContentItem[]> GetContentItems(ContentItemQuery query) { if (String.IsNullOrEmpty(query.AppId)) { throw new ArgumentException("NoDbStorage always requires the AppId property"); } var contentItems = await _contentItemQueries.GetAllAsync(query.AppId); if (!string.IsNullOrEmpty(query.Id)) { contentItems = contentItems.Where(ci => ci.Id == query.Id); } if (!string.IsNullOrEmpty(query.CollectionId)) { contentItems = contentItems.Where(ci => ci.CollectionId == query.CollectionId); } if (!string.IsNullOrEmpty(query.ContentKey)) { contentItems = contentItems.Where(ci => string.Equals(ci.ContentKey, query.ContentKey, StringComparison.InvariantCultureIgnoreCase)); } if (!string.IsNullOrEmpty(query.ContentKeyStartsWith)) { contentItems = contentItems.Where(ci => ci.ContentKey.StartsWith(query.ContentKeyStartsWith, StringComparison.InvariantCultureIgnoreCase)); } switch (query.OrderBy) { case ContentItemQuery.ContentItemsOrderBy.LastModifiedAtDescending: contentItems = contentItems.OrderByDescending(ci => ci.LastModifiedAt); break; case ContentItemQuery.ContentItemsOrderBy.ContentKey: contentItems = contentItems.OrderBy(ci => ci.ContentKey); break; } if (query.Offset.HasValue) { contentItems = contentItems.Skip(query.Offset.Value); } if (query.First.HasValue) { contentItems = contentItems.Take(query.First.Value); } return(contentItems.ToArray()); }
private async Task <List <IdentityResource> > GetAll(string siteId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); //TODO: cache var allScopes = await _queries.GetAllAsync(siteId).ConfigureAwait(false); return(allScopes.ToList()); }
public async Task <IGeoCountry> FetchCountry( string isoCode2, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var all = await countryQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var countries = all.ToList().AsQueryable(); return(countries.Where( x => x.ISOCode2 == isoCode2 ) .SingleOrDefault()); }
public async Task DeleteByContent( string projectId, string contentId, CancellationToken cancellationToken = default(CancellationToken) ) { var items = await _queries.GetAllAsync(projectId).ConfigureAwait(false); var query = items.ToList().AsQueryable(); var filtered = query.Where(x => x.ContentId == contentId && x.ProjectId == projectId); foreach (var item in filtered) { await _commands.DeleteAsync( projectId, item.Id.ToString(), cancellationToken).ConfigureAwait(false); } }
public async Task <IKvpItem> FetchByKey( string projectId, string key, string featureId = "*", string setId = "*", string subSetId = "*", CancellationToken cancellationToken = default(CancellationToken) ) { var all = await _kvpQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); return(all.Where( x => x.Key == key && (featureId == "*" || x.FeatureId == featureId) && (setId == "*" || x.SetId == setId) && (subSetId == "*" || x.SubSetId == subSetId) ).FirstOrDefault()); }
private async Task <List <Page> > GetAllPages( string projectId, CancellationToken cancellationToken) { var l = await _query.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var list = l.ToList(); return(list); }
private async Task <List <Post> > GetAllPosts( string blogId, CancellationToken cancellationToken) { var l = await query.GetAllAsync(blogId, cancellationToken).ConfigureAwait(false); var list = l.ToList(); return(list); }
public async Task <ProductDomain> Get(int sku) { var listDB = await _productDBRead.GetAllAsync(DB).ConfigureAwait(false); if (listDB.Any()) { return(listDB.Where(x => x.Sku.Equals(sku)).FirstOrDefault()); } return(null); }
public async Task <ActionResult <JsonPagedResult <IEnumerable <Question> > > > GetAllQuestions(bool randomise = false) { var results = await _pageQueriesQuestion.GetAllAsync("Cues"); var list = randomise ? results.OrderBy(x => x.Sequence).ToList() : results.ToList(); if (!list.Any()) { return(new JsonPagedResult <IEnumerable <Question> > { Total = 0 }); } return(new JsonPagedResult <IEnumerable <Question> > { Total = list.Count, Rows = list }); }
public async Task <JsonPagedResult <IEnumerable <Category> > > GetCategories() { var results = await _pageQueriesCategory.GetAllAsync("Cues"); var enumerable = results.ToList(); if (!enumerable.Any()) { return(new JsonPagedResult <IEnumerable <Category> > { Total = 0 }); } return(new JsonPagedResult <IEnumerable <Category> > { Total = enumerable.Count, Rows = enumerable }); }
public async Task <PagedResult <ContentHistory> > GetByContent( string projectId, string contentId, int pageNumber = 1, int pageSize = 10, CancellationToken cancellationToken = default(CancellationToken) ) { cancellationToken.ThrowIfCancellationRequested(); int offset = (pageSize * pageNumber) - pageSize; var all = await _queries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); var list = all.ToList().AsQueryable(); var query = list .Where(x => x.ProjectId == projectId && x.ContentId == contentId ); var count = query.Count(); query = query .OrderByDescending(x => x.ArchivedUtc) .Select(p => p) .Skip(offset) .Take(pageSize); var result = new PagedResult <ContentHistory> { PageNumber = pageNumber, PageSize = pageSize, Data = query.ToList(), TotalItems = count }; return(result); }
public async Task <List <ICurrency> > GetAllCurrencies(CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var all = await currencyQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); return(all.OrderBy(x => x.Title) .Select(x => x).ToList <ICurrency>()); }