mirror of https://github.com/abpframework/eventhub
19 changed files with 652 additions and 4 deletions
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Admin.Events.Registrations |
||||
|
{ |
||||
|
public class EventAttendeeDto : 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,17 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace EventHub.Admin.Events.Registrations |
||||
|
{ |
||||
|
public interface IEventRegistrationAppService : IApplicationService |
||||
|
{ |
||||
|
Task<PagedResultDto<EventAttendeeDto>> GetAttendeesAsync(Guid eventId); |
||||
|
|
||||
|
Task RemoveAttendeeAsync(Guid eventId, Guid attendeeId); |
||||
|
|
||||
|
Task RegisterUsersAsync(Guid eventId, List<Guid> userIds); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Admin.Users |
||||
|
{ |
||||
|
public class GetUnregisteredUserEventInput : PagedResultRequestDto |
||||
|
{ |
||||
|
public Guid EventId { get; set; } |
||||
|
public string Username { get; set; } |
||||
|
public string Name { get; set; } |
||||
|
public string Surname { get; set; } |
||||
|
public string Email { get; set; } |
||||
|
public string Sorting { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace EventHub.Admin.Users |
||||
|
{ |
||||
|
public interface IUserAppService : IApplicationService |
||||
|
{ |
||||
|
Task<PagedResultDto<UserDto>> GetUnregisteredUsersOfEventAsync(GetUnregisteredUserEventInput input); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Auditing; |
||||
|
|
||||
|
namespace EventHub.Admin.Users |
||||
|
{ |
||||
|
public class UserDto : EntityDto<Guid>, IHasCreationTime |
||||
|
{ |
||||
|
public string Username { get; set; } |
||||
|
|
||||
|
public string Email { get; set; } |
||||
|
|
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string Surname { get; set; } |
||||
|
|
||||
|
public DateTime CreationTime { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using EventHub.Admin.Permissions; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
using EventHub.Events.Registrations; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using EventHub.Events; |
||||
|
|
||||
|
namespace EventHub.Admin.Events.Registrations |
||||
|
{ |
||||
|
//[Authorize(EventHubPermissions.Events.Registrations.Default)]
|
||||
|
public class EventRegistrationAppService : EventHubAdminAppService, IEventRegistrationAppService |
||||
|
{ |
||||
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
||||
|
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository; |
||||
|
private readonly IRepository<Event, Guid> _eventRepository; |
||||
|
private readonly EventRegistrationManager _eventRegistrationManager; |
||||
|
|
||||
|
|
||||
|
public EventRegistrationAppService( |
||||
|
IRepository<IdentityUser, Guid> userRepository, |
||||
|
IRepository<EventRegistration, Guid> eventRegistrationRepository, |
||||
|
IRepository<Event, Guid> eventRepository, |
||||
|
EventRegistrationManager eventRegistrationManager) |
||||
|
{ |
||||
|
_userRepository = userRepository; |
||||
|
_eventRegistrationRepository = eventRegistrationRepository; |
||||
|
_eventRepository = eventRepository; |
||||
|
_eventRegistrationManager = eventRegistrationManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<PagedResultDto<EventAttendeeDto>> GetAttendeesAsync(Guid eventId) |
||||
|
{ |
||||
|
var eventRegistrationQueryable = await _eventRegistrationRepository.GetQueryableAsync(); |
||||
|
var userQueryable = await _userRepository.GetQueryableAsync(); |
||||
|
|
||||
|
var query = from eventRegistration in eventRegistrationQueryable |
||||
|
join user in userQueryable on eventRegistration.UserId equals user.Id |
||||
|
where eventRegistration.EventId == eventId |
||||
|
orderby eventRegistration.CreationTime descending |
||||
|
select user; |
||||
|
|
||||
|
var totalCount = await AsyncExecuter.CountAsync(query); |
||||
|
var users = await AsyncExecuter.ToListAsync(query.Take(10)); |
||||
|
|
||||
|
return new PagedResultDto<EventAttendeeDto>( |
||||
|
totalCount, |
||||
|
ObjectMapper.Map<List<IdentityUser>, List<EventAttendeeDto>>(users) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
//[Authorize(EventHubPermissions.Events.Registrations.RemoveAttendee)]
|
||||
|
public async Task RemoveAttendeeAsync(Guid eventId, Guid attendeeId) |
||||
|
{ |
||||
|
await _eventRegistrationManager.UnregisterAsync( |
||||
|
await _eventRepository.GetAsync(eventId), |
||||
|
await _userRepository.GetAsync(attendeeId) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
//[Authorize(EventHubPermissions.Events.Registrations.AddAttendee)]
|
||||
|
public async Task RegisterUsersAsync(Guid eventId, List<Guid> userIds) |
||||
|
{ |
||||
|
if (userIds == null || !userIds.Any()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var @event = await _eventRepository.GetAsync(eventId); |
||||
|
|
||||
|
var userQueryable = await _userRepository.GetQueryableAsync(); |
||||
|
var query = userQueryable.Where(user => userIds.Contains(user.Id)); |
||||
|
|
||||
|
var users = await AsyncExecuter.ToListAsync(query); |
||||
|
|
||||
|
foreach (var user in users) |
||||
|
{ |
||||
|
await _eventRegistrationManager.RegisterAsync(@event, user); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using EventHub.Events.Registrations; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
using Volo.Abp.Identity; |
||||
|
|
||||
|
namespace EventHub.Admin.Users |
||||
|
{ |
||||
|
public class UserAppService : EventHubAdminAppService, IUserAppService |
||||
|
{ |
||||
|
private readonly IRepository<IdentityUser, Guid> _identityUserRepository; |
||||
|
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository; |
||||
|
|
||||
|
public UserAppService(IRepository<IdentityUser, Guid> identityUserRepository, IRepository<EventRegistration, Guid> eventRegistrationRepository) |
||||
|
{ |
||||
|
_identityUserRepository = identityUserRepository; |
||||
|
_eventRegistrationRepository = eventRegistrationRepository; |
||||
|
} |
||||
|
|
||||
|
public async Task<PagedResultDto<UserDto>> GetUnregisteredUsersOfEventAsync(GetUnregisteredUserEventInput input) |
||||
|
{ |
||||
|
var identityUserQueryable = await _identityUserRepository.GetQueryableAsync(); |
||||
|
|
||||
|
var eventRegistrationQuery = (await _eventRegistrationRepository.GetQueryableAsync()) |
||||
|
.Where(x => x.EventId == input.EventId) |
||||
|
.Select(x => x.UserId); |
||||
|
|
||||
|
var userIds = await AsyncExecuter.ToListAsync(eventRegistrationQuery); |
||||
|
|
||||
|
var query = identityUserQueryable |
||||
|
.Where(x => !userIds.Contains(x.Id)) |
||||
|
.WhereIf(!string.IsNullOrWhiteSpace(input.Username), user => user.UserName.ToLower().Contains(input.Username.ToLower())) |
||||
|
.WhereIf(!string.IsNullOrWhiteSpace(input.Name), user => user.Name.ToLower().Contains(input.Name.ToLower())) |
||||
|
.WhereIf(!string.IsNullOrWhiteSpace(input.Surname), user => user.Surname.ToLower().Contains(input.Surname.ToLower())) |
||||
|
.WhereIf(!string.IsNullOrWhiteSpace(input.Email), user => user.Email.ToLower().Contains(input.Email.ToLower())); |
||||
|
|
||||
|
var totalCount = await AsyncExecuter.CountAsync(query); |
||||
|
|
||||
|
query = query.PageBy(input); |
||||
|
|
||||
|
var users = await AsyncExecuter.ToListAsync(query); |
||||
|
|
||||
|
return new PagedResultDto<UserDto>(totalCount, ObjectMapper.Map<List<IdentityUser>, List<UserDto>>(users)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using EventHub.Admin.Events.Registrations; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace EventHub.Admin.Controllers.Events.Registrations |
||||
|
{ |
||||
|
[RemoteService(Name = EventHubAdminRemoteServiceConsts.RemoteServiceName)] |
||||
|
[Controller] |
||||
|
[Area("eventhub-admin")] |
||||
|
[ControllerName("EventRegistration")] |
||||
|
[Route("/api/eventhub/admin/event-registration")] |
||||
|
public class EventRegistrationController : AbpController, IEventRegistrationAppService |
||||
|
{ |
||||
|
private readonly IEventRegistrationAppService _eventRegistrationAppService; |
||||
|
|
||||
|
public EventRegistrationController(IEventRegistrationAppService eventRegistrationAppService) |
||||
|
{ |
||||
|
_eventRegistrationAppService = eventRegistrationAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet("{eventId}")] |
||||
|
public Task<PagedResultDto<EventAttendeeDto>> GetAttendeesAsync(Guid eventId) |
||||
|
{ |
||||
|
return _eventRegistrationAppService.GetAttendeesAsync(eventId); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
public Task RegisterUsersAsync(Guid eventId, List<Guid> userIds) |
||||
|
{ |
||||
|
return _eventRegistrationAppService.RegisterUsersAsync(eventId, userIds); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public Task RemoveAttendeeAsync(Guid eventId, Guid attendeeId) |
||||
|
{ |
||||
|
return _eventRegistrationAppService.RemoveAttendeeAsync(eventId, attendeeId); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using EventHub.Admin.Users; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace EventHub.Admin.Controllers.Users |
||||
|
{ |
||||
|
[RemoteService(Name = EventHubAdminRemoteServiceConsts.RemoteServiceName)] |
||||
|
[Controller] |
||||
|
[Area("eventhub-admin")] |
||||
|
[ControllerName("User")] |
||||
|
[Route("/api/eventhub/admin/user")] |
||||
|
public class UserController : AbpController, IUserAppService |
||||
|
{ |
||||
|
private readonly IUserAppService _userAppService; |
||||
|
|
||||
|
public UserController(IUserAppService userAppService) |
||||
|
{ |
||||
|
_userAppService = userAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public Task<PagedResultDto<UserDto>> GetUnregisteredUsersOfEventAsync(GetUnregisteredUserEventInput input) |
||||
|
{ |
||||
|
return _userAppService.GetUnregisteredUsersOfEventAsync(input); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
@inherits EventHubComponentBase |
||||
@ -0,0 +1,160 @@ |
|||||
|
@page "/events/{EventId:guid}/attendees" |
||||
|
@using EventHub.Admin.Web.Components.UserPicker |
||||
|
@using EventHub.Admin.Events.Registrations |
||||
|
@using EventHub.Admin.Permissions |
||||
|
@using EventHub.Admin.Users |
||||
|
@inherits EventHubComponentBase |
||||
|
@inject IEventRegistrationAppService EventRegistrationAppService |
||||
|
@inject IUserAppService UserAppService |
||||
|
|
||||
|
<!--<UserPicker />--> |
||||
|
<Card> |
||||
|
<CardHeader> |
||||
|
@* ************************* PAGE HEADER ************************* *@ |
||||
|
<h2>@L["Attendees"]</h2> |
||||
|
|
||||
|
<Paragraph Alignment="TextAlignment.Right"> |
||||
|
@if (CanAddAttendee) |
||||
|
{ |
||||
|
<Button Color="Color.Primary" |
||||
|
Clicked="OpenAddAttendeeModal"> |
||||
|
@L["AddNewUser"] |
||||
|
</Button> |
||||
|
} |
||||
|
</Paragraph> |
||||
|
</CardHeader> |
||||
|
|
||||
|
<CardBody> |
||||
|
@* ************************* DATA GRID ************************* *@ |
||||
|
<DataGrid TItem="EventAttendeeDto" |
||||
|
Data="AttendeeList" |
||||
|
ReadData="OnDataGridReadAsync" |
||||
|
TotalItems="TotalCount" |
||||
|
ShowPager="true" |
||||
|
PageSize="PageSize" |
||||
|
Responsive="true"> |
||||
|
<DataGridColumns> |
||||
|
<DataGridEntityActionsColumn TItem="EventAttendeeDto"> |
||||
|
<DisplayTemplate> |
||||
|
<EntityActions TItem="EventAttendeeDto"> |
||||
|
<EntityAction TItem="EventAttendeeDto" |
||||
|
RequiredPolicy="@EventHubPermissions.Events.Registrations.RemoveAttendee" |
||||
|
Clicked="() => RemoveAttendeeAsync(context)" |
||||
|
ConfirmationMessage="@(() => L["AttendeeRemoveConfirmationMessage"])" |
||||
|
Text="@L["RemoveUser"]"> |
||||
|
</EntityAction> |
||||
|
</EntityActions> |
||||
|
</DisplayTemplate> |
||||
|
</DataGridEntityActionsColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="EventAttendeeDto" |
||||
|
Field="UserName" |
||||
|
Caption="@L["Username"]"> |
||||
|
</DataGridColumn> |
||||
|
<DataGridColumn TItem="EventAttendeeDto" |
||||
|
Field="Name" |
||||
|
Caption="@L["Name"]"> |
||||
|
</DataGridColumn> |
||||
|
<DataGridColumn TItem="EventAttendeeDto" |
||||
|
Field="Surname" |
||||
|
Caption="@L["Surname"]"> |
||||
|
</DataGridColumn> |
||||
|
<DataGridColumn TItem="EventAttendeeDto" |
||||
|
Field="Email" |
||||
|
Caption="@L["Email"]"> |
||||
|
</DataGridColumn> |
||||
|
</DataGridColumns> |
||||
|
</DataGrid> |
||||
|
</CardBody> |
||||
|
</Card> |
||||
|
|
||||
|
|
||||
|
<Modal @ref="@AddAttendeeModal" Closing="@ClosingAddAttendeeModal"> |
||||
|
<ModalContent Centered="true"> |
||||
|
<ModalHeader> |
||||
|
<ModalTitle>@L["AddAttendee"]</ModalTitle> |
||||
|
<CloseButton Clicked="CloseAddAttendeeModalAsync" /> |
||||
|
</ModalHeader> |
||||
|
<ModalBody> |
||||
|
<Form> |
||||
|
<div id="UserFilterSection" class="row mt-3"> |
||||
|
<Column ColumnSize="ColumnSize.Is3"> |
||||
|
<Field> |
||||
|
<FieldLabel>@L["Username"]</FieldLabel> |
||||
|
<TextEdit TValue="string" KeyPress="OnKeyPressed" @bind-Text="@Filter.Username" /> |
||||
|
</Field> |
||||
|
</Column> |
||||
|
<Column ColumnSize="ColumnSize.Is3"> |
||||
|
<Field> |
||||
|
<FieldLabel>@L["Name"]</FieldLabel> |
||||
|
<TextEdit TValue="string" KeyPress="OnKeyPressed" @bind-Text="@Filter.Name" /> |
||||
|
</Field> |
||||
|
</Column> |
||||
|
<Column ColumnSize="ColumnSize.Is3"> |
||||
|
<Field> |
||||
|
<FieldLabel>@L["Surname"]</FieldLabel> |
||||
|
<TextEdit TValue="string" KeyPress="OnKeyPressed" @bind-Text="@Filter.Surname" /> |
||||
|
</Field> |
||||
|
</Column> |
||||
|
<Column ColumnSize="ColumnSize.Is3"> |
||||
|
<Field> |
||||
|
<FieldLabel>@L["Email"]</FieldLabel> |
||||
|
<TextEdit TValue="string" KeyPress="OnKeyPressed" @bind-Text="@Filter.Email" /> |
||||
|
</Field> |
||||
|
</Column> |
||||
|
</div> |
||||
|
</Form> |
||||
|
|
||||
|
<DataGrid TItem="UserDto" |
||||
|
Data="UserList" |
||||
|
ReadData="OnDataGridReadForUsersAsync" |
||||
|
TotalItems="UserListTotalCount" |
||||
|
ShowPager="true" |
||||
|
PageSize="PageSize" |
||||
|
Responsive="true"> |
||||
|
<DataGridColumns> |
||||
|
<DataGridColumn Sortable="false" TItem="UserDto" Field="@nameof(UserDto.Id)"> |
||||
|
<CaptionTemplate> |
||||
|
<Check TValue="bool" @bind-Checked="@AllUserSelected"></Check> |
||||
|
</CaptionTemplate> |
||||
|
<DisplayTemplate> |
||||
|
@if (SelectAllUsers.ContainsKey(context.Id)) |
||||
|
{ |
||||
|
<Check TValue="bool" @bind-Checked="@SelectAllUsers[context.Id]"></Check> |
||||
|
} |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Username)" Caption="@L["UserName"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Username) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Name)" Caption="@L["Name"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Name) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Surname)" Caption="@L["Surname"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Surname) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Email)" Caption="@L["Email"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Email) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
</DataGridColumns> |
||||
|
</DataGrid> |
||||
|
</ModalBody> |
||||
|
<ModalFooter> |
||||
|
<Button Color="Color.Secondary" Clicked="CloseAddAttendeeModalAsync">@L["Cancel"]</Button> |
||||
|
<Button Color="Color.Primary" Clicked="AddSelectedUsersToEventAsync">@L["Save"]</Button> |
||||
|
</ModalFooter> |
||||
|
</ModalContent> |
||||
|
</Modal> |
||||
|
|
||||
@ -0,0 +1,170 @@ |
|||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using EventHub.Admin.Events.Registrations; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Blazorise; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Blazorise.DataGrid; |
||||
|
using EventHub.Admin.Permissions; |
||||
|
using EventHub.Admin.Users; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Components.Web; |
||||
|
|
||||
|
namespace EventHub.Admin.Web.Pages |
||||
|
{ |
||||
|
public partial class AttendeeDetail |
||||
|
{ |
||||
|
[Parameter] |
||||
|
public Guid EventId { get; set; } |
||||
|
private IReadOnlyList<EventAttendeeDto> AttendeeList { get; set; } |
||||
|
private int CurrentPage { get; set; } |
||||
|
private string CurrentSorting { get; set; } |
||||
|
private int TotalCount { get; set; } |
||||
|
private int PageSize { get; } |
||||
|
private bool CanAddAttendee { get; set; } |
||||
|
private Modal AddAttendeeModal { get; set; } |
||||
|
private GetUnregisteredUserEventInput Filter { get; set; } |
||||
|
private IReadOnlyList<UserDto> UserList { get; set; } |
||||
|
private int UserListTotalCount { get; set; } |
||||
|
|
||||
|
private Dictionary<Guid, bool> SelectAllUsers = new(); |
||||
|
|
||||
|
private bool AllUserSelected |
||||
|
{ |
||||
|
get => SelectAllUsers.All(x => x.Value); |
||||
|
set |
||||
|
{ |
||||
|
foreach (var key in SelectAllUsers.Keys) |
||||
|
{ |
||||
|
SelectAllUsers[key] = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public AttendeeDetail() |
||||
|
{ |
||||
|
PageSize = LimitedResultRequestDto.DefaultMaxResultCount; |
||||
|
Filter = new GetUnregisteredUserEventInput(); |
||||
|
} |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
await SetPermissionsAsync(); |
||||
|
await GetAttendeesAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task GetAttendeesAsync() |
||||
|
{ |
||||
|
var result = await EventRegistrationAppService.GetAttendeesAsync(EventId); |
||||
|
|
||||
|
AttendeeList = result.Items; |
||||
|
TotalCount = (int)result.TotalCount; |
||||
|
} |
||||
|
|
||||
|
private async Task SetPermissionsAsync() |
||||
|
{ |
||||
|
CanAddAttendee = await AuthorizationService.IsGrantedAsync(EventHubPermissions.Events.Registrations.AddAttendee); |
||||
|
} |
||||
|
|
||||
|
private async Task OnDataGridReadAsync(DataGridReadDataEventArgs<EventAttendeeDto> 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 GetAttendeesAsync(); |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
private async Task RemoveAttendeeAsync(EventAttendeeDto attendee) |
||||
|
{ |
||||
|
await EventRegistrationAppService.RemoveAttendeeAsync(EventId, attendee.Id); |
||||
|
await GetAttendeesAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task OpenAddAttendeeModal() |
||||
|
{ |
||||
|
AddAttendeeModal.Show(); |
||||
|
await GetUsersAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task GetUsersAsync() |
||||
|
{ |
||||
|
Filter.EventId = EventId; |
||||
|
Filter.MaxResultCount = PageSize; |
||||
|
Filter.SkipCount = CurrentPage * PageSize; |
||||
|
Filter.Sorting = CurrentSorting; |
||||
|
|
||||
|
var result = await UserAppService.GetUnregisteredUsersOfEventAsync(Filter); |
||||
|
UserList = result.Items; |
||||
|
UserListTotalCount = (int)result.TotalCount; |
||||
|
|
||||
|
FillSelectedUserList(); |
||||
|
} |
||||
|
|
||||
|
private void FillSelectedUserList() |
||||
|
{ |
||||
|
SelectAllUsers = new Dictionary<Guid, bool>(); |
||||
|
|
||||
|
foreach (var user in UserList) |
||||
|
{ |
||||
|
SelectAllUsers.Add(user.Id, false); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task OnKeyPressed(KeyboardEventArgs e) |
||||
|
{ |
||||
|
if (e.Code is "Enter" or "NumpadEnter") |
||||
|
{ |
||||
|
await GetUsersAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task OnDataGridReadForUsersAsync(DataGridReadDataEventArgs<UserDto> 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 GetUsersAsync(); |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
private async Task AddSelectedUsersToEventAsync() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var selectedUserIds= SelectAllUsers |
||||
|
.Where(x => x.Value) |
||||
|
.Select(x => x.Key) |
||||
|
.ToList(); |
||||
|
|
||||
|
await EventRegistrationAppService.RegisterUsersAsync(EventId, selectedUserIds); |
||||
|
await CloseAddAttendeeModalAsync(); |
||||
|
|
||||
|
await GetAttendeesAsync(); |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
await HandleErrorAsync(ex); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ClosingAddAttendeeModal(ModalClosingEventArgs eventArgs) |
||||
|
{ |
||||
|
eventArgs.Cancel = eventArgs.CloseReason == CloseReason.FocusLostClosing; |
||||
|
} |
||||
|
|
||||
|
private Task CloseAddAttendeeModalAsync() |
||||
|
{ |
||||
|
AddAttendeeModal.Hide(); |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue