mirror of https://github.com/abpframework/eventhub
23 changed files with 812 additions and 33 deletions
@ -0,0 +1,11 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace EventHub.Admin.Organizations.Memberships |
|||
{ |
|||
public interface IOrganizationMembershipAppService : IApplicationService |
|||
{ |
|||
Task<PagedResultDto<OrganizationMemberDto>> GetListAsync(OrganizationMemberListFilterDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace EventHub.Admin.Organizations.Memberships |
|||
{ |
|||
public class OrganizationMemberDto : EntityDto<Guid> |
|||
{ |
|||
public string UserName { get; set; } |
|||
|
|||
public string Email { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string Surname { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace EventHub.Admin.Organizations.Memberships |
|||
{ |
|||
public class OrganizationMemberListFilterDto : PagedResultRequestDto |
|||
{ |
|||
public Guid? OrganizationId { get; set; } |
|||
|
|||
public string UserName { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using EventHub.Admin.Permissions; |
|||
using EventHub.Organizations.Memberships; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
|
|||
|
|||
namespace EventHub.Admin.Organizations.Memberships |
|||
{ |
|||
[Authorize(EventHubPermissions.Organizations.Memberships.Default)] |
|||
public class OrganizationMembershipAppService : ApplicationService, IOrganizationMembershipAppService |
|||
{ |
|||
private readonly IOrganizationMembershipRepository _organizationMembershipRepository; |
|||
private readonly IRepository<IdentityUser, Guid> _userRepository; |
|||
|
|||
public OrganizationMembershipAppService( |
|||
IOrganizationMembershipRepository organizationMembershipRepository, |
|||
IRepository<IdentityUser, Guid> userRepository) |
|||
{ |
|||
_organizationMembershipRepository = organizationMembershipRepository; |
|||
_userRepository = userRepository; |
|||
} |
|||
|
|||
public async Task<PagedResultDto<OrganizationMemberDto>> GetListAsync(OrganizationMemberListFilterDto input) |
|||
{ |
|||
IdentityUser user = null; |
|||
if (!input.UserName.IsNullOrWhiteSpace()) |
|||
{ |
|||
input.UserName = input.UserName.ToLower(); |
|||
user = await _userRepository.SingleOrDefaultAsync(x => x.UserName.ToLower().Contains(input.UserName)); |
|||
if (user is null) |
|||
{ |
|||
throw new EntityNotFoundException(typeof(IdentityUser), input.UserName); |
|||
} |
|||
} |
|||
|
|||
var members = await _organizationMembershipRepository.GetMemberListAsync(input.OrganizationId, user?.Id, input.SkipCount, input.MaxResultCount); |
|||
var totalCount = await _organizationMembershipRepository.GetCountAsync(input.OrganizationId, user?.Id); |
|||
|
|||
return new PagedResultDto<OrganizationMemberDto>( |
|||
totalCount, |
|||
ObjectMapper.Map<List<IdentityUser>, List<OrganizationMemberDto>>(members) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Threading.Tasks; |
|||
using EventHub.Admin.Organizations.Memberships; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace EventHub.Admin.Controllers.Organizations.Memberships |
|||
{ |
|||
[Controller] |
|||
[Area("eventhub-admin")] |
|||
[ControllerName("OrganizationMembership")] |
|||
[Route("/api/eventhub/organization-memberships")] |
|||
public class OrganizationMembershipController : AbpController, IOrganizationMembershipAppService |
|||
{ |
|||
private readonly IOrganizationMembershipAppService _organizationMembershipAppService; |
|||
|
|||
public OrganizationMembershipController(IOrganizationMembershipAppService organizationMembershipAppService) |
|||
{ |
|||
_organizationMembershipAppService = organizationMembershipAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
public async Task<PagedResultDto<OrganizationMemberDto>> GetListAsync(OrganizationMemberListFilterDto input) |
|||
{ |
|||
return await _organizationMembershipAppService.GetListAsync(input); |
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,11 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using EventHub.Admin.Application.Contracts.Organizations; |
|||
using EventHub.Admin.Organizations; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace EventHub.Admin.Controllers |
|||
namespace EventHub.Admin.Controllers.Organizations |
|||
{ |
|||
[Controller] |
|||
[Area("eventhub-admin")] |
|||
@ -0,0 +1,255 @@ |
|||
@page "/organizations" |
|||
@using Volo.Abp.BlazoriseUI.Components |
|||
@using EventHub.Admin.Permissions |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using EventHub.Admin.Organizations |
|||
@using EventHub.Organizations |
|||
@inherits EventHubComponentBase |
|||
@inject NavigationManager NavigationManager |
|||
@attribute [Authorize(EventHubPermissions.Organizations.Default)] |
|||
@inject IOrganizationAppService OrganizationAppService |
|||
|
|||
<Card> |
|||
<CardHeader> |
|||
@* ************************* PAGE HEADER ************************* *@ |
|||
<h2>@L["Organizations"]</h2> |
|||
</CardHeader> |
|||
|
|||
@* ************************* SEARCH ************************* *@ |
|||
|
|||
<CardBody> |
|||
<Form> |
|||
<div id="FilterSection" class="row mt-3"> |
|||
<Column ColumnSize="ColumnSize.Is3"> |
|||
<Field> |
|||
<FieldLabel>@L["Name"]</FieldLabel> |
|||
<TextEdit TValue="string" KeyPress="OnKeyPress" @bind-Text="@Filter.Name"/> |
|||
</Field> |
|||
</Column> |
|||
|
|||
<Column ColumnSize="ColumnSize.Is3"> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName"]</FieldLabel> |
|||
<TextEdit TValue="string" KeyPress="OnKeyPress" @bind-Text="@Filter.DisplayName"/> |
|||
</Field> |
|||
</Column> |
|||
|
|||
<Column ColumnSize="ColumnSize.Is3"> |
|||
<Field> |
|||
<FieldLabel>@L["MinMemberCount"]</FieldLabel> |
|||
<NumericEdit TValue="int?" KeyPress="OnKeyPress" @bind-Value="@Filter.MinMemberCount"/> |
|||
</Field> |
|||
</Column> |
|||
|
|||
<Column ColumnSize="ColumnSize.Is3"> |
|||
<Field> |
|||
<FieldLabel>@L["MaxMemberCount"]</FieldLabel> |
|||
<NumericEdit TValue="int?" KeyPress="OnKeyPress" @bind-Value="@Filter.MaxMemberCount"/> |
|||
</Field> |
|||
</Column> |
|||
</div> |
|||
</Form> |
|||
|
|||
@* ************************* DATA GRID ************************* *@ |
|||
<DataGrid TItem="OrganizationInListDto" |
|||
Data="OrganizationList" |
|||
ReadData="OnDataGridReadAsync" |
|||
TotalItems="TotalCount" |
|||
ShowPager="true" |
|||
PageSize="PageSize" |
|||
Responsive="true"> |
|||
<DataGridColumns> |
|||
<DataGridEntityActionsColumn TItem="OrganizationInListDto"> |
|||
<DisplayTemplate> |
|||
<EntityActions TItem="OrganizationInListDto"> |
|||
<EntityAction TItem="OrganizationInListDto" |
|||
RequiredPolicy="@EventHubPermissions.Organizations.Memberships.Default" |
|||
Clicked="@(() => NavigationManager.NavigateTo($"/organization-memberships/{context.Id}"))" |
|||
Text="@L["Members"]"></EntityAction> |
|||
<EntityAction TItem="OrganizationInListDto" |
|||
RequiredPolicy="@EventHubPermissions.Organizations.Update" |
|||
Clicked="() => OpenEditOrganizationModal(context)" |
|||
Text="@L["Edit"]"> |
|||
</EntityAction> |
|||
<EntityAction TItem="OrganizationInListDto" |
|||
RequiredPolicy="@EventHubPermissions.Organizations.Delete" |
|||
Clicked="() => DeleteOrganizationAsync(context)" |
|||
ConfirmationMessage="@(() => L["DeleteConfirmationMessage"])" |
|||
Text="@L["Delete"]"> |
|||
</EntityAction> |
|||
</EntityActions> |
|||
</DisplayTemplate> |
|||
</DataGridEntityActionsColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationInListDto" |
|||
Field="Name" |
|||
Caption="@L["Name"]"> |
|||
</DataGridColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationInListDto" |
|||
Field="DisplayName" |
|||
Caption="@L["DisplayName"]"> |
|||
</DataGridColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationInListDto" |
|||
Field="MemberCount" |
|||
Caption="@L["MemberCount"]"> |
|||
</DataGridColumn> |
|||
</DataGridColumns> |
|||
</DataGrid> |
|||
</CardBody> |
|||
</Card> |
|||
|
|||
@* ************************* EDIT MODAL ************************* *@ |
|||
|
|||
<Modal @ref="EditOrganizationModal" Closing="@OnEditModalClosing"> |
|||
<ModalContent Centered="true" Size="ModalSize.Large"> |
|||
<Form id="EditOrganizationForm"> |
|||
<ModalHeader> |
|||
<ModalTitle>@L["UpdateOrganization"]</ModalTitle> |
|||
<CloseButton Clicked="() => EditOrganizationModal.Hide()"/> |
|||
</ModalHeader> |
|||
<ModalBody> |
|||
<Tabs SelectedTab="@SelectedTabInEditModal" SelectedTabChanged="@OnSelectedTabChangedInEditModal"> |
|||
<Items> |
|||
<Tab Name="@TabContentInEditModal.OrganizationProfile.ToString()">Organization Info</Tab> |
|||
<Tab Name="@TabContentInEditModal.ProfileImage.ToString()">Profile Image</Tab> |
|||
</Items> |
|||
<Content> |
|||
<TabPanel Name="@TabContentInEditModal.OrganizationProfile.ToString()"> |
|||
<Validations Mode="ValidationMode.Auto" Model="@EditOrganizationModal" ValidateOnLoad="false"> |
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName"] *</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.DisplayName"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["Description"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.Description"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["Website"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.Website"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["TwitterUsername"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.TwitterUsername"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["GitHubUsername"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.GitHubUsername"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["FacebookUsername"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.FacebookUsername"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["InstagramUsername"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.InstagramUsername"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
<Validation> |
|||
<Field> |
|||
<FieldLabel>@L["MediumUsername"]</FieldLabel> |
|||
<TextEdit TValue="string" @bind-Text="@EditingOrganization.MediumUsername"> |
|||
<Feedback> |
|||
<ValidationError/> |
|||
</Feedback> |
|||
</TextEdit> |
|||
</Field> |
|||
</Validation> |
|||
|
|||
</Validations> |
|||
</TabPanel> |
|||
<TabPanel Name="@TabContentInEditModal.ProfileImage.ToString()"> |
|||
@if (!ProfileImageUrl.IsNullOrEmpty()) |
|||
{ |
|||
@if (!IsLoadingProfileImage) |
|||
{ |
|||
<div class="text-center mt-4"> |
|||
<img src="@ProfileImageUrl" class="organization-profile-img" width="600" height="340" alt="profile-image"/> |
|||
</div> |
|||
} |
|||
else |
|||
{ |
|||
<div class="d-flex justify-content-center mt-4"> |
|||
<div class="spinner-border" role="status"> |
|||
<span class="sr-only">Loading...</span> |
|||
</div> |
|||
</div> |
|||
} |
|||
} |
|||
|
|||
<div class="mt-3 mb-5"> |
|||
<Field Horizontal="true"> |
|||
<FieldLabel ColumnSize="ColumnSize.Is3">@L["ChooseProfileImage"]</FieldLabel> |
|||
<FieldBody ColumnSize="ColumnSize.Is9"> |
|||
<FileEdit MaxMessageSize="@OrganizationConsts.MaxProfilePictureFileSize" Filter=".jpg, .png" Changed="@OnProfileImageFileChanged" Progressed="@OnProgressedForProfileImage" AutoReset="true"/> |
|||
</FieldBody> |
|||
</Field> |
|||
</div> |
|||
</TabPanel> |
|||
</Content> |
|||
</Tabs> |
|||
</ModalBody> |
|||
<ModalFooter> |
|||
<Button Color="Color.Secondary" |
|||
Clicked="() => EditOrganizationModal.Hide()"> |
|||
@L["Cancel"] |
|||
</Button> |
|||
<Button Type="ButtonType.Submit" PreventDefaultOnSubmit="true" Color="Color.Primary" |
|||
Clicked="UpdateOrganizationAsync"> |
|||
<i class="fa-check fa"></i> @L["Save"] |
|||
</Button> |
|||
</ModalFooter> |
|||
</Form> |
|||
</ModalContent> |
|||
</Modal> |
|||
@ -0,0 +1,162 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Blazorise; |
|||
using Blazorise.DataGrid; |
|||
using EventHub.Admin.Organizations; |
|||
using Microsoft.AspNetCore.Components.Web; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace EventHub.Admin.Web.Pages |
|||
{ |
|||
public partial class OrganizationManagement |
|||
{ |
|||
private IReadOnlyList<OrganizationInListDto> OrganizationList { get; set; } |
|||
private OrganizationListFilterDto Filter { get; set; } |
|||
private int CurrentPage { get; set; } |
|||
private string CurrentSorting { get; set; } |
|||
private int TotalCount { get; set; } |
|||
private int PageSize { get; } |
|||
|
|||
private OrganizationProfileDto Organization { get; set; } |
|||
private string ProfileImageUrl { get; set; } |
|||
|
|||
private Guid EditingOrganizationId { get; set; } |
|||
private UpdateOrganizationDto EditingOrganization { get; set; } |
|||
private Modal EditOrganizationModal { get; set; } |
|||
private IFileEntry FileEntry { get; set; } |
|||
private bool IsLoadingProfileImage { get; set; } |
|||
private string SelectedTabInEditModal { get; set; } |
|||
|
|||
public OrganizationManagement() |
|||
{ |
|||
Filter = new OrganizationListFilterDto(); |
|||
PageSize = LimitedResultRequestDto.DefaultMaxResultCount; |
|||
|
|||
OrganizationList = new List<OrganizationInListDto>(); |
|||
EditingOrganization = new UpdateOrganizationDto(); |
|||
IsLoadingProfileImage = false; |
|||
SelectedTabInEditModal = TabContentInEditModal.OrganizationProfile.ToString(); |
|||
} |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
await GetOrganizationsAsync(); |
|||
} |
|||
|
|||
private async Task OnDataGridReadAsync(DataGridReadDataEventArgs<OrganizationInListDto> e) |
|||
{ |
|||
CurrentSorting = e.Columns |
|||
.Where(c => c.Direction != SortDirection.None) |
|||
.Select(c => c.Field + (c.Direction == SortDirection.Descending ? " DESC" : "")) |
|||
.JoinAsString(","); |
|||
CurrentPage = e.Page - 1; |
|||
await GetOrganizationsAsync(); |
|||
await InvokeAsync(StateHasChanged); |
|||
} |
|||
|
|||
private async Task GetOrganizationsAsync() |
|||
{ |
|||
Filter.MaxResultCount = PageSize; |
|||
Filter.SkipCount = CurrentPage * PageSize; |
|||
Filter.Sorting = CurrentSorting; |
|||
|
|||
var result = await OrganizationAppService.GetListAsync(Filter); |
|||
OrganizationList = result.Items; |
|||
TotalCount = (int) result.TotalCount; |
|||
} |
|||
|
|||
private async Task OpenEditOrganizationModal(OrganizationInListDto input) |
|||
{ |
|||
EditingOrganizationId = input.Id; |
|||
Organization = await OrganizationAppService.GetAsync(EditingOrganizationId); |
|||
FillProfileImageUrl(Organization.ProfilePictureContent); |
|||
|
|||
EditingOrganization = ObjectMapper.Map<OrganizationProfileDto, UpdateOrganizationDto>(Organization); |
|||
EditOrganizationModal.Show(); |
|||
} |
|||
|
|||
private async Task UpdateOrganizationAsync() |
|||
{ |
|||
await OrganizationAppService.UpdateAsync(EditingOrganizationId, EditingOrganization); |
|||
await GetOrganizationsAsync(); |
|||
EditOrganizationModal.Hide(); |
|||
} |
|||
|
|||
private async Task DeleteOrganizationAsync(OrganizationInListDto organization) |
|||
{ |
|||
await OrganizationAppService.DeleteAsync(organization.Id); |
|||
await GetOrganizationsAsync(); |
|||
} |
|||
|
|||
private async Task OnProfileImageFileChanged(FileChangedEventArgs e) |
|||
{ |
|||
IsLoadingProfileImage = true; |
|||
|
|||
if (e.Files != null && e.Files.Any()) |
|||
{ |
|||
FileEntry = e.Files[0]; |
|||
|
|||
if (FileEntry != null) |
|||
{ |
|||
using (var stream = new MemoryStream()) |
|||
{ |
|||
await FileEntry.WriteToStreamAsync(stream); |
|||
|
|||
stream.Seek(0, SeekOrigin.Begin); |
|||
EditingOrganization.ProfilePictureContent = stream.ToArray(); |
|||
FillProfileImageUrl(EditingOrganization.ProfilePictureContent); |
|||
await InvokeAsync(StateHasChanged); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void FillProfileImageUrl(byte[] content) |
|||
{ |
|||
if (content != null) |
|||
{ |
|||
var imageBase64Data = Convert.ToBase64String(content); |
|||
var imageDataUrl = $"data:image/png;base64,{imageBase64Data}"; |
|||
ProfileImageUrl = imageDataUrl; |
|||
} |
|||
} |
|||
|
|||
private void OnProgressedForProfileImage(FileProgressedEventArgs e) |
|||
{ |
|||
if (e.Percentage == 100D) |
|||
{ |
|||
IsLoadingProfileImage = false; |
|||
} |
|||
} |
|||
|
|||
private void OnSelectedTabChangedInEditModal(string name) |
|||
{ |
|||
SelectedTabInEditModal = name; |
|||
} |
|||
|
|||
private void OnEditModalClosing(CancelEventArgs e) |
|||
{ |
|||
IsLoadingProfileImage = false; |
|||
SelectedTabInEditModal = TabContentInEditModal.OrganizationProfile.ToString(); |
|||
|
|||
} |
|||
|
|||
private async Task OnKeyPress(KeyboardEventArgs e) |
|||
{ |
|||
if (e.Code == "Enter" || e.Code == "NumpadEnter") |
|||
{ |
|||
await GetOrganizationsAsync(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public enum TabContentInEditModal : byte |
|||
{ |
|||
OrganizationProfile = 0, |
|||
ProfileImage |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
@page "/organization-memberships/{OrganizationId:guid?}" |
|||
@using Volo.Abp.BlazoriseUI.Components |
|||
@using EventHub.Admin.Organizations.Memberships |
|||
@using EventHub.Admin.Permissions |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@inherits EventHubComponentBase |
|||
@attribute [Authorize(EventHubPermissions.Organizations.Memberships.Default)] |
|||
@inject IOrganizationMembershipAppService OrganizationMembershipAppService |
|||
|
|||
<Card> |
|||
<CardHeader> |
|||
@* ************************* HEADER ************************* *@ |
|||
<h2> |
|||
@L["OrganizationMemberships"] |
|||
@if (OrganizationId.HasValue && !OrganizationName.IsNullOrWhiteSpace()) |
|||
{ |
|||
<span> (@OrganizationName)</span> |
|||
} |
|||
</h2> |
|||
</CardHeader> |
|||
|
|||
@* ************************* SEARCH ************************* *@ |
|||
<CardBody> |
|||
<div id="FilterSection" class="mt-3 ml-2"> |
|||
<Field> |
|||
<FieldLabel>@L["UserName"]</FieldLabel> |
|||
<TextEdit TValue="string" KeyPress="OnKeyPress" @bind-Text="@Filter.UserName"/> |
|||
</Field> |
|||
</div> |
|||
|
|||
@* ************************* DATA GRID ************************* *@ |
|||
<DataGrid TItem="OrganizationMemberDto" |
|||
Data="OrganizationMemberList" |
|||
ReadData="OnDataGridReadAsync" |
|||
TotalItems="TotalCount" |
|||
ShowPager="true" |
|||
PageSize="PageSize" |
|||
Responsive="true" |
|||
Sortable="false"> |
|||
<DataGridColumns> |
|||
<DataGridColumn TItem="OrganizationMemberDto" |
|||
Field="UserName" |
|||
Caption="@L["UserName"]"> |
|||
</DataGridColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationMemberDto" |
|||
Field="Email" |
|||
Caption="@L["Email"]"> |
|||
</DataGridColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationMemberDto" |
|||
Field="Name" |
|||
Caption="@L["Name"]"> |
|||
</DataGridColumn> |
|||
|
|||
<DataGridColumn TItem="OrganizationMemberDto" |
|||
Field="Surname" |
|||
Caption="@L["Surname"]"> |
|||
</DataGridColumn> |
|||
</DataGridColumns> |
|||
</DataGrid> |
|||
</CardBody> |
|||
</Card> |
|||
@ -0,0 +1,76 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Blazorise.DataGrid; |
|||
using EventHub.Admin.Organizations; |
|||
using EventHub.Admin.Organizations.Memberships; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.AspNetCore.Components.Web; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace EventHub.Admin.Web.Pages |
|||
{ |
|||
public partial class OrganizationMembershipManagement |
|||
{ |
|||
[Parameter] |
|||
public Guid? OrganizationId { get; set; } |
|||
public string OrganizationName { get; set; } |
|||
[Inject] |
|||
protected IOrganizationAppService OrganizationAppService { get; set; } |
|||
|
|||
|
|||
private IReadOnlyList<OrganizationMemberDto> OrganizationMemberList { get; set; } |
|||
private OrganizationMemberListFilterDto Filter { get; set; } |
|||
private int CurrentPage { get; set; } |
|||
private int TotalCount { get; set; } |
|||
private int PageSize { get; } |
|||
|
|||
public OrganizationMembershipManagement() |
|||
{ |
|||
Filter = new OrganizationMemberListFilterDto(); |
|||
PageSize = LimitedResultRequestDto.DefaultMaxResultCount; |
|||
|
|||
OrganizationMemberList = new List<OrganizationMemberDto>(); |
|||
} |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
await GetOrganizationMembershipsAsync(); |
|||
|
|||
if (OrganizationId.HasValue) |
|||
{ |
|||
OrganizationName = (await OrganizationAppService.GetAsync(OrganizationId.Value)).Name; |
|||
} |
|||
} |
|||
|
|||
private async Task OnDataGridReadAsync(DataGridReadDataEventArgs<OrganizationMemberDto> e) |
|||
{ |
|||
CurrentPage = e.Page - 1; |
|||
await GetOrganizationMembershipsAsync(); |
|||
await InvokeAsync(StateHasChanged); |
|||
} |
|||
|
|||
private async Task GetOrganizationMembershipsAsync() |
|||
{ |
|||
Filter.MaxResultCount = PageSize; |
|||
Filter.SkipCount = CurrentPage * PageSize; |
|||
|
|||
if (OrganizationId.HasValue) |
|||
{ |
|||
Filter.OrganizationId = OrganizationId!.Value; |
|||
} |
|||
|
|||
var result = await OrganizationMembershipAppService.GetListAsync(Filter); |
|||
OrganizationMemberList = result.Items; |
|||
TotalCount = (int) result.TotalCount; |
|||
} |
|||
|
|||
private async Task OnKeyPress(KeyboardEventArgs e) |
|||
{ |
|||
if (e.Code == "Enter" || e.Code == "NumpadEnter") |
|||
{ |
|||
await GetOrganizationMembershipsAsync(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace EventHub.Organizations.Memberships |
|||
{ |
|||
public interface IOrganizationMembershipRepository : IRepository<OrganizationMembership, Guid> |
|||
{ |
|||
Task<List<IdentityUser>> GetMemberListAsync( |
|||
Guid? organizationId, |
|||
Guid? userId, |
|||
int skipCount, |
|||
int maxResultCount, |
|||
CancellationToken cancellationToken = default); |
|||
|
|||
Task<int> GetCountAsync( |
|||
Guid? organizationId, |
|||
Guid? userId, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using EventHub.Organizations.Memberships; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace EventHub.EntityFrameworkCore.Organizations.Memberships |
|||
{ |
|||
public class OrganizationMembershipRepository : EfCoreRepository<EventHubDbContext, OrganizationMembership, Guid>, IOrganizationMembershipRepository |
|||
{ |
|||
public OrganizationMembershipRepository(IDbContextProvider<EventHubDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public async Task<List<IdentityUser>> GetMemberListAsync( |
|||
Guid? organizationId, |
|||
Guid? userId, |
|||
int skipCount, |
|||
int maxResultCount, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var dbContext = await GetDbContextAsync(); |
|||
|
|||
var organizationMembershipsDbSet = dbContext.Set<OrganizationMembership>(); |
|||
var identityUserDbSet = dbContext.Set<IdentityUser>(); |
|||
|
|||
var query = organizationMembershipsDbSet |
|||
.Join(identityUserDbSet, organizationMember => organizationMember.UserId, user => user.Id, |
|||
(organizationMember, user) => new {organizationMember, user}) |
|||
.WhereIf(userId.HasValue, t => t.user.Id == userId) |
|||
.WhereIf(organizationId.HasValue, t => t.organizationMember.OrganizationId == organizationId) |
|||
.OrderByDescending(x => x.organizationMember.CreationTime) |
|||
.Select(x => x.user); |
|||
|
|||
return await query |
|||
.PageBy(skipCount, maxResultCount) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public async Task<int> GetCountAsync( |
|||
Guid? organizationId, |
|||
Guid? userId, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
var dbContext = await GetDbContextAsync(); |
|||
|
|||
var organizationMembershipsDbSet = dbContext.Set<OrganizationMembership>(); |
|||
var identityUserDbSet = dbContext.Set<IdentityUser>(); |
|||
|
|||
return await organizationMembershipsDbSet |
|||
.Join(identityUserDbSet, organizationMember => organizationMember.UserId, user => user.Id, |
|||
(organizationMember, user) => new {organizationMember, user}) |
|||
.WhereIf(userId.HasValue, t => t.user.Id == userId) |
|||
.WhereIf(organizationId.HasValue, t => t.organizationMember.OrganizationId == organizationId) |
|||
.CountAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue