|
|
@ -3,6 +3,7 @@ using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using EventHub.Organizations; |
|
|
using EventHub.Organizations.Memberships; |
|
|
using EventHub.Organizations.Memberships; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|
|
@ -18,7 +19,7 @@ namespace EventHub.EntityFrameworkCore.Organizations.Memberships |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async Task<List<IdentityUser>> GetMemberListAsync( |
|
|
public async Task<List<OrganizationMemberWithDetails>> GetMemberListAsync( |
|
|
Guid? organizationId, |
|
|
Guid? organizationId, |
|
|
Guid? userId, |
|
|
Guid? userId, |
|
|
int skipCount, |
|
|
int skipCount, |
|
|
@ -29,14 +30,24 @@ namespace EventHub.EntityFrameworkCore.Organizations.Memberships |
|
|
|
|
|
|
|
|
var organizationMembershipsDbSet = dbContext.Set<OrganizationMembership>(); |
|
|
var organizationMembershipsDbSet = dbContext.Set<OrganizationMembership>(); |
|
|
var identityUserDbSet = dbContext.Set<IdentityUser>(); |
|
|
var identityUserDbSet = dbContext.Set<IdentityUser>(); |
|
|
|
|
|
var organizationDbSet = dbContext.Set<Organization>(); |
|
|
|
|
|
|
|
|
var query = organizationMembershipsDbSet |
|
|
var query = organizationMembershipsDbSet |
|
|
.Join(identityUserDbSet, organizationMember => organizationMember.UserId, user => user.Id, |
|
|
.Join(organizationDbSet, t => t.OrganizationId, organization => organization.Id |
|
|
(organizationMember, user) => new {organizationMember, user}) |
|
|
, (organizationMember, organization) => new {organizationMember, organization}) |
|
|
|
|
|
.Join(identityUserDbSet, organizationWithMember => organizationWithMember.organizationMember.UserId, user => user.Id, |
|
|
|
|
|
(organizationWithMember, user) => new {organizationWithMember, user}) |
|
|
.WhereIf(userId.HasValue, t => t.user.Id == userId) |
|
|
.WhereIf(userId.HasValue, t => t.user.Id == userId) |
|
|
.WhereIf(organizationId.HasValue, t => t.organizationMember.OrganizationId == organizationId) |
|
|
.WhereIf(organizationId.HasValue, t => t.organizationWithMember.organizationMember.OrganizationId == organizationId) |
|
|
.OrderByDescending(x => x.organizationMember.CreationTime) |
|
|
.OrderByDescending(o => o.organizationWithMember.organizationMember.CreationTime) |
|
|
.Select(x => x.user); |
|
|
.Select(t => new OrganizationMemberWithDetails |
|
|
|
|
|
{ |
|
|
|
|
|
OrganizationName = t.organizationWithMember.organization.Name, |
|
|
|
|
|
UserName = t.user.UserName, |
|
|
|
|
|
Email = t.user.Email, |
|
|
|
|
|
Name = t.user.Name, |
|
|
|
|
|
Surname = t.user.Surname |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return await query |
|
|
return await query |
|
|
.PageBy(skipCount, maxResultCount) |
|
|
.PageBy(skipCount, maxResultCount) |
|
|
|