IdentityServer Repositories

pull/533/head
Yunus Emre Kalkan 7 years ago
parent b8d04ddd19
commit 3ce9c1148d

@ -22,7 +22,7 @@ namespace Volo.Blogging.Blogs
{
var blogs = await _blogRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount );
var totalCount = await _blogRepository.GetTotalBlogCount();
var totalCount = await _blogRepository.GetTotalCount();
var dtos = ObjectMapper.Map<List<Blog>, List<BlogDto>>(blogs);

@ -11,6 +11,6 @@ namespace Volo.Blogging.Blogs
Task<List<Blog>> GetListAsync(string sorting, int maxResultCount, int skipCount);
Task<int> GetTotalBlogCount();
Task<int> GetTotalCount();
}
}

@ -32,7 +32,7 @@ namespace Volo.Blogging.Blogs
return auditLogs;
}
public async Task<int> GetTotalBlogCount()
public async Task<int> GetTotalCount()
{
return await DbSet.CountAsync();
}

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
@ -15,6 +15,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\abp\framework\src\Volo.Abp.Core\Volo.Abp.Core.csproj" />
<ProjectReference Include="..\..\..\..\..\abp\framework\src\Volo.Abp.Localization\Volo.Abp.Localization.csproj" />
</ItemGroup>
</Project>

@ -1,9 +1,19 @@
using Volo.Abp.Modularity;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.IdentityServer.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
namespace Volo.Abp.IdentityServer
{
public class AbpIdentityServerDomainSharedModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Configure<AbpLocalizationOptions>(options =>
{
options.Resources.Add<AbpIdentityServerResource>("en");
});
}
}
}

@ -0,0 +1,10 @@
using Volo.Abp.Localization;
namespace Volo.Abp.IdentityServer.Localization
{
[LocalizationResourceName("AbpIdentityServer")]
public class AbpIdentityServerResource
{
}
}

@ -15,8 +15,18 @@ namespace Volo.Abp.IdentityServer.IdentityResources
);
Task<List<IdentityResource>> GetListAsync(
string sorting,
int skipCount,
int maxResultCount,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<IdentityResource>> GetListAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<long> GetTotalBlogCount();
}
}

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.IdentityServer.IdentityResources
{
@ -43,5 +44,19 @@ namespace Volo.Abp.IdentityServer.IdentityResources
{
return GetQueryable().IncludeDetails();
}
public virtual async Task<List<IdentityResource>> GetListAsync(string sorting, int skipCount, int maxResultCount,
bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails).OrderBy(sorting ?? "name desc")
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalBlogCount()
{
return await DbSet.CountAsync();
}
}
}

@ -8,6 +8,8 @@ using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.IdentityServer.MongoDB
{
@ -17,6 +19,15 @@ namespace Volo.Abp.IdentityServer.MongoDB
{
}
public virtual async Task<List<IdentityResource>> GetListAsync(string sorting, int skipCount, int maxResultCount, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.OrderBy(sorting ?? nameof(IdentityResource.Name))
.As<IMongoQueryable<IdentityResource>>()
.PageBy<IdentityResource, IMongoQueryable<IdentityResource>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityResource>> GetListByScopesAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -24,5 +35,10 @@ namespace Volo.Abp.IdentityServer.MongoDB
.Where(ar => scopeNames.Contains(ar.Name))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalBlogCount()
{
return await GetCountAsync();
}
}
}

@ -10,10 +10,10 @@ using Xunit;
namespace Volo.Abp.IdentityServer
{
public class IdentityResourceRepository_Tests<TStartupModule> : AbpIdentityServerTestBase<TStartupModule>
public abstract class IdentityResourceRepository_Tests<TStartupModule> : AbpIdentityServerTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IIdentityResourceRepository identityResourceRepository;
protected IIdentityResourceRepository identityResourceRepository;
public IdentityResourceRepository_Tests()
{

Loading…
Cancel
Save