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);
        }
Example #2
0
        //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);
        }
Example #3
0
        // 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));
        }
Example #4
0
 public async Task <Client> FindClientByIdAsync(string clientId)
 {
     return(await _queries.FetchAsync(
                _siteId, // aka nodb projectid
                clientId
                ).ConfigureAwait(false));
 }
Example #5
0
        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);
        }
Example #6
0
        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());
        }
Example #7
0
        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);
        }
Example #8
0
        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));
        }
Example #9
0
        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));
        }
Example #10
0
        //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));
        }
Example #11
0
        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));
        }
Example #12
0
        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));
        }
Example #13
0
        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));
        }
Example #14
0
        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());
        }
Example #15
0
        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);
        }
Example #16
0
        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);
            }
        }
Example #19
0
        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);
        }
Example #20
0
        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." }));
        }
Example #21
0
 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));
 }
Example #23
0
 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()));
 }
Example #25
0
 public Task <ContentItem> GetContentItem(string id, string appId)
 {
     return(_contentItemQueries.FetchAsync(appId, id));
 }
Example #26
0
 public Task <App> GetApp(string id)
 {
     return(_appQueries.FetchAsync(Constants.ApplicationsProjectId, id));
 }
Example #27
0
 public async Task <PersistedGrant> GetAsync(string key)
 {
     return(await _queries.FetchAsync(_siteId, key).ConfigureAwait(false));
 }
Example #28
0
 public async Task <IdentityResource> FetchIdentityResource(string siteId, string name, CancellationToken cancellationToken = default(CancellationToken))
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(await _queries.FetchAsync(siteId, name, cancellationToken).ConfigureAwait(false));
 }