public async Task Update( string projectId, IPost post, CancellationToken cancellationToken = default(CancellationToken) ) { var p = Post.FromIPost(post); p.LastModified = DateTime.UtcNow; //since we store posts in year month folders we need to check if pubdate changed and move the file if needed by delete and re-reate. var currentVersion = await _query.FetchAsync(projectId, p.Id); if (currentVersion.PubDate != p.PubDate) { await _commands.DeleteAsync(projectId, p.Id).ConfigureAwait(false); await _commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); } else { await _commands.UpdateAsync(projectId, p.Id, p).ConfigureAwait(false); } _cache.ClearListCache(projectId); }
//public async Task FlagAsDeleted( // Guid siteId, // Guid userId, // CancellationToken cancellationToken = default(CancellationToken)) //{ // ThrowIfDisposed(); // cancellationToken.ThrowIfCancellationRequested(); // //await EnsureProjectId().ConfigureAwait(false); // var projectId = siteId.ToString(); // var item // = await userQueries.FetchAsync( // projectId, // userId.ToString(), // cancellationToken).ConfigureAwait(false); // if (item == null) { throw new InvalidOperationException("user not found"); } // item.IsDeleted = true; // await userCommands.UpdateAsync( // projectId, // item.Id.ToString(), // item, // cancellationToken).ConfigureAwait(false); //} //public async Task FlagAsNotDeleted( // Guid siteId, // Guid userId, // CancellationToken cancellationToken = default(CancellationToken)) //{ // ThrowIfDisposed(); // cancellationToken.ThrowIfCancellationRequested(); // //await EnsureProjectId().ConfigureAwait(false); // var projectId = siteId.ToString(); // var item // = await userQueries.FetchAsync( // projectId, // userId.ToString(), // cancellationToken).ConfigureAwait(false); // if (item == null) { throw new InvalidOperationException("user not found"); } // item.IsDeleted = false; // await userCommands.UpdateAsync( // projectId, // item.Id.ToString(), // item, // cancellationToken).ConfigureAwait(false); //} public async Task LockoutAccount( Guid siteId, Guid userId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); var item = await userQueries.FetchAsync( projectId, userId.ToString(), cancellationToken).ConfigureAwait(false); if (item == null) { throw new InvalidOperationException("user not found"); } item.IsLockedOut = true; await userCommands.UpdateAsync( projectId, item.Id.ToString(), item, cancellationToken).ConfigureAwait(false); }
// need custom NoDb logic for option to lookup across projects public async Task <ISiteSettings> Fetch( Guid siteId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); return(await queries.FetchAsync( projectId, siteId.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <Client> FindClientByIdAsync(string clientId) { return(await _queries.FetchAsync( _siteId, // aka nodb projectid clientId ).ConfigureAwait(false)); }
public async Task <Client> FindClientByIdAsync(string clientId) { var site = _contextAccessor.HttpContext.GetTenant <SiteContext>(); if (site == null) { return(null); } var client = await _queries.FetchAsync( site.Id.ToString(), // aka nodb projectid clientId ).ConfigureAwait(false); if (client != null) { var clientClaims = await GetClientClaims(site.Id.ToString(), client.ClientId).ConfigureAwait(false); foreach (var cc in clientClaims) { var c = new System.Security.Claims.Claim(cc.Type, cc.Value); client.Claims.Add(c); } } return(client); }
public async Task <IActionResult> UpdateQuestion(Question question) { var q = _pageQueriesQuestion.FetchAsync("Cues", question.Id.ToString()).Result; if (q != null) { q.Title = question.Title; q.InternalName = q.Title.ToSlug(); q.Answer = question.Answer; q.CategoryId = question.CategoryId ?? q.CategoryId; await _pageCommandsQuestion.UpdateAsync("Cues", q.Id.ToString(), q); } else { return(NotFound()); } return(new NoContentResult()); }
public async Task <IPost> GetPost( string blogId, string postId, CancellationToken cancellationToken = default(CancellationToken) ) { return(await query.FetchAsync(blogId, postId, cancellationToken).ConfigureAwait(false)); //var allPosts = await GetAllPosts(blogId, cancellationToken).ConfigureAwait(false); //return allPosts.FirstOrDefault(p => p.Id == postId); }
public async Task <AuthorizationPolicyInfo> Fetch( string tenantId, Guid policyId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); return(await _policyQueries.FetchAsync( tenantId, policyId.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <IGeoZone> FetchGeoZone( Guid stateId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); return(await stateQueries.FetchAsync( projectId, stateId.ToString(), cancellationToken).ConfigureAwait(false)); }
//public async Task<ILanguage> FetchLanguage( // Guid languageId, // CancellationToken cancellationToken = default(CancellationToken)) //{ // ThrowIfDisposed(); // cancellationToken.ThrowIfCancellationRequested(); // await EnsureProjectId().ConfigureAwait(false); // return await langQueries.FetchAsync( // projectId, // languageId.ToString(), // cancellationToken).ConfigureAwait(false); //} //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; //} //public async Task<List<ILanguage>> GetAllLanguages(CancellationToken cancellationToken = default(CancellationToken)) //{ // ThrowIfDisposed(); // cancellationToken.ThrowIfCancellationRequested(); // await EnsureProjectId().ConfigureAwait(false); // var all = await langQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); // return all.OrderBy( // x => x.Name).ToList<ILanguage>(); //} //public async Task<List<ILanguage>> GetLanguagePage( // int pageNumber, // int pageSize, // CancellationToken cancellationToken = default(CancellationToken)) //{ // ThrowIfDisposed(); // cancellationToken.ThrowIfCancellationRequested(); // await EnsureProjectId().ConfigureAwait(false); // var all = await langQueries.GetAllAsync(projectId, cancellationToken).ConfigureAwait(false); // int offset = (pageSize * pageNumber) - pageSize; // return all.OrderBy(x => x.Name) // .Skip(offset) // .Take(pageSize) // .Select(x => x).ToList<ILanguage>(); //} public async Task <ICurrency> FetchCurrency( Guid currencyId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); return(await currencyQueries.FetchAsync( projectId, currencyId.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <ContentHistory> Fetch( string projectId, Guid id, CancellationToken cancellationToken = default(CancellationToken) ) { cancellationToken.ThrowIfCancellationRequested(); return(await _queries.FetchAsync( projectId, id.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <IGeoCountry> FetchCountry( Guid countryId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var projectId = "default"; return(await countryQueries.FetchAsync( projectId, countryId.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <ILanguage> FetchLanguage( Guid languageId, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); return(await langQueries.FetchAsync( projectId, languageId.ToString(), cancellationToken).ConfigureAwait(false)); }
public async Task <IActionResult> CreateCategory([FromBody] Category category) { category.Id = new Random().Next(0, 100000000); category.InternalName = category.Title.ToSlug(); if (category.ParentCategoryId == 0) { await _pageCommandsCategory.CreateAsync("Cues", category.Id.ToString(), category); return(CreatedAtAction("GetCategory", new { id = category.Id }, category)); } var findParent = await _pageQueriesCategory.FetchAsync("Cues", category.ParentCategoryId.ToString()); if (findParent != null) { await _pageCommandsCategory.CreateAsync("Cues", category.Id.ToString(), category); return(CreatedAtAction("GetCategory", new { id = category.Id }, category)); } return(BadRequest()); }
public async Task <IKvpItem> FetchById( string projectId, string itemId, CancellationToken cancellationToken = default(CancellationToken) ) { cancellationToken.ThrowIfCancellationRequested(); var item = await _kvpQueries.FetchAsync( projectId, itemId.ToString(), cancellationToken).ConfigureAwait(false); return(item); }
public async Task <IProjectSettings> GetProjectSettings( string projectId, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); var result = configProjects.Where(b => b.Id == projectId).FirstOrDefault(); if (result != null) { return(result); } result = await queries.FetchAsync(projectId, projectId, cancellationToken); return(result); }
public async Task Delete( string projectId, string postId, CancellationToken cancellationToken = default(CancellationToken) ) { var post = await query.FetchAsync(projectId, postId, cancellationToken).ConfigureAwait(false); if (post != null) { var allPosts = await GetAllPosts(projectId, CancellationToken.None).ConfigureAwait(false); await commands.DeleteAsync(projectId, postId).ConfigureAwait(false); allPosts.Remove(post); } }
public async Task Delete( string projectId, string pageId, CancellationToken cancellationToken = default(CancellationToken) ) { var page = await _query.FetchAsync(projectId, pageId, CancellationToken.None); if (page != null) { var pages = await GetAllPages(projectId, CancellationToken.None).ConfigureAwait(false); await _commands.DeleteAsync(projectId, pageId).ConfigureAwait(false); pages.Remove(page); } }
public async Task <Client> FetchClient(string siteId, string clientId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var client = await _queries.FetchAsync(siteId, clientId, cancellationToken).ConfigureAwait(false); if (client != null) { var clientClaims = await GetClientClaims(siteId, client.ClientId, cancellationToken).ConfigureAwait(false); foreach (var cc in clientClaims) { var c = new System.Security.Claims.Claim(cc.Type, cc.Value); client.Claims.Add(c); } } return(client); }
public async Task <IActionResult> Get(string id) { var card = await cardQueries.FetchAsync("BlueShift", id); return(card != null ? (IActionResult)Ok(card) : BadRequest(new { error = $"Card with id [{id}] does not exist. You must create a card with this id to retrieve it." })); }
public async Task <Scope> FetchScope(string siteId, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); return(await _queries.FetchAsync(siteId, scopeName, cancellationToken).ConfigureAwait(false)); }
public async Task <JournalEntry> GetJournalById(string journalId) { return(await query.FetchAsync(PROJECT_ID, journalId)); }
async Task <T> IRepository <T> .FindByIdAsync(Guid Id) { return(await _applicationQueries.FetchAsync(ProjectId, Id.ToString())); }
async Task <ToggleSchedule> IRepository <ToggleSchedule> .FindByIdAsync(Guid id) { return(await _toggleScheduleQueries.FetchAsync(ProjectId, id.ToString())); }
public Task <ContentItem> GetContentItem(string id, string appId) { return(_contentItemQueries.FetchAsync(appId, id)); }
public Task <App> GetApp(string id) { return(_appQueries.FetchAsync(Constants.ApplicationsProjectId, id)); }
public async Task <PersistedGrant> GetAsync(string key) { return(await _queries.FetchAsync(_siteId, key).ConfigureAwait(false)); }
public async Task <IdentityResource> FetchIdentityResource(string siteId, string name, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); return(await _queries.FetchAsync(siteId, name, cancellationToken).ConfigureAwait(false)); }