renaming organizationUnit namepsace

pull/3732/head
Galip Tolga Erdem 6 years ago
parent a75459d480
commit cdf8cf9907

@ -1,6 +1,6 @@
namespace Volo.Abp.Identity.Organizations
namespace Volo.Abp.Identity
{
public class OrganizationUnitConsts
public static class OrganizationUnitConsts
{
/// <summary>
/// Maximum length of the <see cref="DisplayName"/> property.

@ -33,4 +33,8 @@
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Volo\Abp\Identity\Organizations\" />
</ItemGroup>
</Project>

@ -5,7 +5,6 @@ using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity
{

@ -4,7 +4,7 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace Volo.Abp.Identity.Organizations
namespace Volo.Abp.Identity
{
public interface IOrganizationUnitRepository : IBasicRepository<OrganizationUnit, Guid>
{

@ -10,7 +10,6 @@ using Microsoft.Extensions.Options;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
using Volo.Abp.Settings;

@ -1,6 +1,5 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Identity

@ -5,7 +5,7 @@ using System.Linq;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Identity.Organizations
namespace Volo.Abp.Identity
{
/// <summary>
/// Represents an organization unit (OU).
@ -52,8 +52,9 @@ namespace Volo.Abp.Identity.Organizations
/// <param name="tenantId">Tenant's Id or null for host.</param>
/// <param name="displayName">Display name.</param>
/// <param name="parentId">Parent's Id or null if OU is a root.</param>
public OrganizationUnit(Guid? tenantId, string displayName, Guid? parentId = null)
public OrganizationUnit(Guid id, string displayName, Guid? parentId = null, Guid? tenantId = null)
{
Id = id;
TenantId = tenantId;
DisplayName = displayName;
ParentId = parentId;

@ -8,7 +8,7 @@ using Volo.Abp.Identity.Localization;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace Volo.Abp.Identity.Organizations
namespace Volo.Abp.Identity
{
/// <summary>
/// Performs domain logic for Organization Units.

@ -2,7 +2,7 @@
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Identity.Organizations
namespace Volo.Abp.Identity
{
/// <summary>
/// Represents membership of a User to an OU.

@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Volo.Abp.Users.EntityFrameworkCore;

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity.EntityFrameworkCore
{
@ -140,6 +139,15 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
join role in DbContext.Roles.IncludeDetails(includeDetails) on userRole.RoleId equals role.Id
where userRole.UserId == id
select role;
//TODO
//var q2 = from userOrganization in DbContext.Set<IdentityUserOrganizationUnit>()
// join userOrg in DbContext.OrganizationUnits.IncludeDetails(includeDetails) on userOrganization.UserId equals id
// select userOrg.Roles;
//var q3 = from ouRole in DbContext.Set<OrganizationUnitRole>()
// join role in DbContext.Roles.IncludeDetails(includeDetails) on ouRole.RoleId equals role.Id
// where ouRole.RoleId == id
// select role;
//query = q2.Union(query);
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}

@ -6,7 +6,6 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity.EntityFrameworkCore
{

@ -1,7 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity.EntityFrameworkCore
{

@ -1,7 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity.EntityFrameworkCore
{

@ -2,7 +2,6 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Users.EntityFrameworkCore;
namespace Volo.Abp.Identity.EntityFrameworkCore

@ -1,6 +1,5 @@
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity.EntityFrameworkCore
{

@ -1,6 +1,5 @@
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MongoDB;
namespace Volo.Abp.Identity.MongoDB

@ -1,5 +1,4 @@
using System;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MongoDB;
namespace Volo.Abp.Identity.MongoDB

@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Volo.Abp.Users.MongoDB;

@ -1,6 +1,5 @@
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MongoDB;
namespace Volo.Abp.Identity.MongoDB

@ -9,7 +9,6 @@ using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.Guids;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MongoDB;
namespace Volo.Abp.Identity.MongoDB

@ -6,7 +6,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.MongoDB;
namespace Volo.Abp.Identity.MongoDB
@ -20,7 +19,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public async Task<List<OrganizationUnit>> GetChildrenAsync(
Guid? parentId,
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -30,8 +29,8 @@ namespace Volo.Abp.Identity.MongoDB
}
public async Task<List<OrganizationUnit>> GetAllChildrenWithParentCodeAsync(
string code,
Guid? parentId,
string code,
Guid? parentId,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -41,7 +40,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public async Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -51,8 +50,8 @@ namespace Volo.Abp.Identity.MongoDB
}
public async Task<OrganizationUnit> GetOrganizationUnitAsync(
string displayName,
bool includeDetails = false,
string displayName,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()

@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Shouldly;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Castle.DynamicProxy;
using Volo.Abp.Uow;
using Xunit;
using System.Linq;
namespace Volo.Abp.Identity
{

@ -1,11 +1,8 @@
using Microsoft.AspNetCore.Identity;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Guids;
using Volo.Abp.Uow;
using Xunit;
@ -19,6 +16,7 @@ namespace Volo.Abp.Identity
private readonly IIdentityRoleRepository _identityRoleRepository;
private readonly ILookupNormalizer _lookupNormalizer;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IGuidGenerator _guidGenerator;
public OrganizationUnitManager_Tests()
{
_organizationUnitManager = GetRequiredService<OrganizationUnitManager>();
@ -27,12 +25,13 @@ namespace Volo.Abp.Identity
_lookupNormalizer = GetRequiredService<ILookupNormalizer>();
_testData = GetRequiredService<IdentityTestData>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_guidGenerator = GetService<IGuidGenerator>();
}
[Fact]
public async Task CreateAsnyc()
{
await _organizationUnitManager.CreateAsync(new OrganizationUnit(null, "Root 1"));
await _organizationUnitManager.CreateAsync(new OrganizationUnit(_guidGenerator.Create(), "Root 1"));
var root1 = await _organizationUnitRepository.GetOrganizationUnitAsync("Root 1");
root1.ShouldNotBeNull();

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity.Organizations;
namespace Volo.Abp.Identity
{
@ -88,7 +87,7 @@ namespace Volo.Abp.Identity
var ou2 = await CreateOU("OU2", OrganizationUnit.CreateCode(2));
var ou21 = await CreateOU("OU21", OrganizationUnit.CreateCode(2, 1), ou2.Id);
_ou111 = new OrganizationUnit(null, "OU111", ou11.Id);
_ou111 = new OrganizationUnit(_guidGenerator.Create(), "OU111", ou11.Id);
_ou111.Code = OrganizationUnit.CreateCode(1, 1, 1);
_ou111.AddRole(_moderatorRole.Id);
_ou111.AddRole(_managerRole.Id);
@ -134,7 +133,7 @@ namespace Volo.Abp.Identity
private async Task<OrganizationUnit> CreateOU(string displayName, string code, Guid? parentId = null)
{
var ou = await _organizationUnitRepository.InsertAsync(new OrganizationUnit(null, displayName, parentId) { Code = code });
var ou = await _organizationUnitRepository.InsertAsync(new OrganizationUnit(_guidGenerator.Create(), displayName, parentId) { Code = code });
return ou;
}
}

@ -5,7 +5,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Xunit;

@ -2,7 +2,6 @@
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Xunit;

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Xunit;

@ -1,13 +1,9 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Guids;
using Volo.Abp.Identity.Organizations;
using Volo.Abp.Modularity;
using Xunit;

Loading…
Cancel
Save