Browse Source

IdentityServer Repositories

pull/533/head
Yunus Emre Kalkan 8 years ago
parent
commit
3ce9c1148d
  1. 2
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs
  2. 2
      modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/IBlogRepository.cs
  3. 2
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs
  4. 3
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.csproj
  5. 14
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/AbpIdentityServerDomainSharedModule.cs
  6. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/AbpIdentityServerResource.cs
  7. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs
  8. 15
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs
  9. 16
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs
  10. 4
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/IdentityResourceRepository_Tests.cs

2
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs

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

2
modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/IBlogRepository.cs

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

2
modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs

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

3
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo.Abp.IdentityServer.Domain.Shared.csproj

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

14
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/AbpIdentityServerDomainSharedModule.cs

@ -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 namespace Volo.Abp.IdentityServer
{ {
public class AbpIdentityServerDomainSharedModule : AbpModule public class AbpIdentityServerDomainSharedModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Configure<AbpLocalizationOptions>(options =>
{
options.Resources.Add<AbpIdentityServerResource>("en");
});
}
} }
} }

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/AbpIdentityServerResource.cs

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

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs

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

15
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs

@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.IdentityServer.IdentityResources namespace Volo.Abp.IdentityServer.IdentityResources
{ {
@ -43,5 +44,19 @@ namespace Volo.Abp.IdentityServer.IdentityResources
{ {
return GetQueryable().IncludeDetails(); 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();
}
} }
} }

16
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

@ -8,6 +8,8 @@ using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.IdentityServer.IdentityResources; using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
using System.Linq.Dynamic.Core;
namespace Volo.Abp.IdentityServer.MongoDB 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, public async Task<List<IdentityResource>> GetListByScopesAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -24,5 +35,10 @@ namespace Volo.Abp.IdentityServer.MongoDB
.Where(ar => scopeNames.Contains(ar.Name)) .Where(ar => scopeNames.Contains(ar.Name))
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public virtual async Task<long> GetTotalBlogCount()
{
return await GetCountAsync();
}
} }
} }

4
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/IdentityResourceRepository_Tests.cs

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

Loading…
Cancel
Save