public async Task <(long Total, List <BlogPost> Posts)> GetBlogPostsAsync(int page = 0, int pageSize = 3) { var query = new ODataQuery { Skip = page * pageSize, Top = pageSize }; var posts = await postsClient.GetAsync(query); return(posts.Total, posts.Items); }
public async Task <Client> FindClientByIdAsync(string clientId) { var clients = await apiClient.GetAsync(filter : $"data/clientId/iv eq '{clientId}'", context : Context.Build()); var client = clients.Items.FirstOrDefault(); if (client == null) { return(null); } return(new Client { AllowAccessTokensViaBrowser = true, AllowedCorsOrigins = client.Data.AllowedCorsOrigins.OrDefault(), AllowedGrantTypes = client.Data.AllowedGrantTypes.OrDefault(), AllowedScopes = client.Data.AllowedScopes.OrDefault(), AllowOfflineAccess = client.Data.AllowOfflineAccess, ClientId = clientId, ClientName = client.Data.ClientName, ClientSecrets = client.Data.ClientSecrets.ToSecrets(), ClientUri = client.Data.ClientUri, LogoUri = apiClientManager.GenerateImageUrl(client.Data.Logo), RedirectUris = client.Data.RedirectUris.OrDefault(), RequireConsent = client.Data.RequireConsent, PostLogoutRedirectUris = client.Data.PostLogoutRedirectUris.OrDefault() }); }
public async Task <List <BlogPostEntity> > GetBlogPosts(int page, int pageSize) { var data = await _blogPostClient.GetAsync(new ODataQuery() { Skip = page *pageSize, Top = pageSize }); return(data.Items); }
public async Task <List <ProjectEntity> > GetProjects(int page, int pageSize) { var data = await _portfolioProjectsClient.GetAsync(new ODataQuery() { Skip = page *pageSize, Top = pageSize }); return(data.Items); }
public Task <List <AuthenticationSchemeData> > GetSchemesAsync() { return(GetOrAddAsync(nameof(AuthenticationSchemeType), async() => { var schemes = await apiClient.GetAsync(context: Context.Build()); return schemes.Items .Select(x => x.Data).GroupBy(x => x.Provider) .Select(x => x.First()) .ToList(); })); }
public async Task <FeaturesDto> GetFeaturesAsync(int version = 0) { var result = new FeaturesDto { Features = new List <FeatureDto>(), Version = FeatureVersion }; if (client != null && version < FeatureVersion) { var features = await client.GetAsync(filter : $"data/version/iv ge {FeatureVersion}", context : Flatten); result.Features.AddRange(features.Items.Select(x => x.Data)); } return(result); }
public async Task Should_read_many_async() { var contents = await client.GetAsync(); for (var i = contents.Total; i < 20000; i++) { await client.CreateAsync(new TestEntityData { String = RandomString.Create(1000) }, publish : true); } var found = await client.GetAll2Async(); Assert.Equal(20000, found.Items.Count); }
public Task <SettingsData> GetSettingsAsync() { return(GetOrAddAsync(nameof(SettingsProvider), async() => { var settings = await apiClient.GetAsync(context: Context.Build()); var result = settings.Items.FirstOrDefault()?.Data ?? new SettingsData(); foreach (var property in result.GetType().GetProperties()) { if (property.GetValue(result) == null) { property.SetValue(result, property.GetValue(defaults.Value)); } } return result; })); }
private Task <(List <IdentityResource> IdentityResources, List <ApiResource> ApiResources)> GetResourcesAsync() { return(GetOrAddAsync(nameof(ResourceStore), async() => { var taskForApiResources = apiApiResources.GetAsync(context: Context.Build()); var taskForIdentityResources = apiIdentityResources.GetAsync(context: Context.Build()); await Task.WhenAll(taskForApiResources, taskForIdentityResources); var identityResources = taskForIdentityResources.Result.Items.Select(x => { var identityResource = new IdentityResource(x.Data.Name, x.Data.DisplayName, x.Data.UserClaims.OrDefault()) { Description = x.Data.Description, Emphasize = true, Required = x.Data.Required }; return identityResource; }).ToList(); identityResources.Add(new IdentityResources.OpenId()); identityResources.Add(new IdentityResources.Profile()); identityResources.Add(new IdentityResources.Email()); identityResources.Add(new IdentityResources.Phone()); identityResources.Add(new DefaultResources.Permissions(localizer)); var apiResources = taskForApiResources.Result.Items.Select(x => { var apiResource = new ApiResource(x.Data.Name, x.Data.DisplayName, x.Data.UserClaims.OrDefault()) { Description = x.Data.Description }; apiResource.Scopes.First().Description = x.Data.Description; return apiResource; }).ToList(); return (identityResources, apiResources); }));
public static async Task <SquidexEntities <TEntity, TData> > GetAll2Async <TEntity, TData>(this SquidexClient <TEntity, TData> client, int batchSize = 200) where TEntity : SquidexEntityBase <TData> where TData : class, new() { var query = new ODataQuery { Top = batchSize, Skip = 0 }; var entities = new SquidexEntities <TEntity, TData>(); do { var getResult = await client.GetAsync(query); entities.Total = getResult.Total; entities.Items.AddRange(getResult.Items); query.Skip += getResult.Items.Count; }while (query.Skip < entities.Total); return(entities); }
public async Task <Client> FindClientByIdAsync(string clientId) { var clients = await apiClient.GetAsync(filter : $"data/clientId/iv eq '{clientId}'", context : Context.Build()); var client = clients.Items.FirstOrDefault(); if (client == null) { return(null); } var scopes = new HashSet <string>(client.Data.AllowedScopes.OrDefault()) { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.Email, DefaultResources.Permissions.Scope }; return(new Client { AllowAccessTokensViaBrowser = true, AllowedCorsOrigins = client.Data.AllowedCorsOrigins.OrDefault(), AllowedGrantTypes = client.Data.AllowedGrantTypes.OrDefault(), AllowedScopes = scopes, AllowOfflineAccess = client.Data.AllowOfflineAccess, ClientId = clientId, ClientName = client.Data.ClientName, ClientSecrets = client.Data.ClientSecrets.ToSecrets(), ClientUri = client.Data.ClientUri, LogoUri = apiClientManager.GenerateImageUrl(client.Data.Logo), RedirectUris = client.Data.RedirectUris.OrDefault(), RequireConsent = client.Data.RequireConsent, PostLogoutRedirectUris = client.Data.PostLogoutRedirectUris.OrDefault() }); }
public async Task <List <Page> > GetPagesAsync() { var pages = await pagesClient.GetAsync(); return(pages.Items); }
public async Task <List <PortfolioProjectEntity> > GetPortfolioProjects(int page = 0, int pageSize = 3) { var data = await _portfolioProjectsClient.GetAsync(page *pageSize, pageSize); return(data.Items); }
public Task <Page> GetPageAsync(string id) { return(pagesClient.GetAsync(id)); }
public async Task <List <Category> > GetCategoriesAsync() { var category = await categoriesClient.GetAsync(); return(category.Items); }
public async Task <PortfolioEntity> GetPortfolio() { var data = await _portfolioClient.GetAsync(); return(data.Items.FirstOrDefault()); }
public async Task <ProfileEntity> GetProfile() { var data = await _profileClient.GetAsync(); return(data.Items.FirstOrDefault()); }
public async Task <List <BlogPostTagEntity> > GetBlogPostTags(int page = 0, int pageSize = 3) { var data = await _blogPostTagClient.GetAsync(page *pageSize, pageSize); return(data.Items); }
public Task <UserEntity> FindByIdAsync(string userId, CancellationToken cancellationToken) { return(apiClient.GetAsync(userId)); }
public async Task <PageIndexEntity> GetPage_Index() { var data = await _pageIndexClient.GetAsync(); return(data.Items.FirstOrDefault()); }
public async Task <PageContactEntity> GetPage_Contact() { var data = await _pageContactClient.GetAsync(); return(data.Items.FirstOrDefault()); }
public async Task <List <AuthorEntity> > GetAuthors() { var data = await _authorsClient.GetAsync(); return(data.Items); }
public async Task <List <SkillTypeEntity> > GetSkillTypes(int page = 0, int pageSize = 3) { var data = await _skillTypesClient.GetAsync(page *pageSize, pageSize); return(data.Items); }
// Begin single schemas public async Task <List <Hero> > GetHeroesAsync() { var hero = await heroesClient.GetAsync(); return(hero.Items); }
public async Task <List <BlogCategoryEntity> > GetBlogCategories(int page = 0, int pageSize = 3) { var data = await _blogCategoriesClient.GetAsync(page *pageSize, pageSize); return(data.Items); }
public async Task <List <Article> > GetArticlesAsync() { var article = await articlesClient.GetAsync(); return(article.Items); }
public async Task <GlobalConfigEntity> GetGlobalConfig() { var data = await _globalClient.GetAsync(); return(data.Items.FirstOrDefault()); }
public async Task <List <Author> > GetAuthorsAsync() { var author = await authorsClient.GetAsync(); return(author.Items); }
public async Task <(long Total, List <BlogPost> Posts)> GetBlogPostsAsync(int page = 0, int pageSize = 3) { var posts = await postsClient.GetAsync(page *pageSize, pageSize); return(posts.Total, posts.Items); }
public async Task <PageSearchResultsEntity> GetPage_SearchResults() { var data = await _pageSearchResultsClient.GetAsync(); return(data.Items.FirstOrDefault()); }