Browse Source

Admin: Create attendees page and list attendees by events

pull/53/head
Engincan VESKE 5 years ago
parent
commit
22f23d5f8d
  1. 16
      src/EventHub.Admin.Application.Contracts/Events/Registrations/EventAttendeeDto.cs
  2. 17
      src/EventHub.Admin.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs
  3. 4
      src/EventHub.Admin.Application.Contracts/Permissions/EventHubPermissionDefinitionProvider.cs
  4. 7
      src/EventHub.Admin.Application.Contracts/Permissions/EventHubPermissions.cs
  5. 15
      src/EventHub.Admin.Application.Contracts/Users/GetUnregisteredUserEventInput.cs
  6. 12
      src/EventHub.Admin.Application.Contracts/Users/IUserAppService.cs
  7. 19
      src/EventHub.Admin.Application.Contracts/Users/UserDto.cs
  8. 6
      src/EventHub.Admin.Application/EventHubApplicationAutoMapperProfile.cs
  9. 3
      src/EventHub.Admin.Application/Events/EventAppService.cs
  10. 86
      src/EventHub.Admin.Application/Events/Registrations/EventRegistrationAppService.cs
  11. 49
      src/EventHub.Admin.Application/Users/UserAppService.cs
  12. 1
      src/EventHub.Admin.HttpApi.Host/Controllers/Events/EventController.cs
  13. 45
      src/EventHub.Admin.HttpApi.Host/Controllers/Events/Registrations/EventRegistrationController.cs
  14. 30
      src/EventHub.Admin.HttpApi.Host/Controllers/Users/UserController.cs
  15. 1
      src/EventHub.Admin.Web/Components/UserPicker/UserPicker.razor
  16. 160
      src/EventHub.Admin.Web/Pages/AttendeeDetail.razor
  17. 170
      src/EventHub.Admin.Web/Pages/AttendeeDetail.razor.cs
  18. 6
      src/EventHub.Admin.Web/Pages/EventManagement.razor
  19. 9
      src/EventHub.Domain.Shared/Localization/EventHub/en.json

16
src/EventHub.Admin.Application.Contracts/Events/Registrations/EventAttendeeDto.cs

@ -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; }
}
}

17
src/EventHub.Admin.Application.Contracts/Events/Registrations/IEventRegistrationAppService.cs

@ -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);
}
}

4
src/EventHub.Admin.Application.Contracts/Permissions/EventHubPermissionDefinitionProvider.cs

@ -18,6 +18,10 @@ namespace EventHub.Admin.Permissions
var eventPermissions = eventHubGroup.AddPermission(EventHubPermissions.Events.Default, L("Permission:EventManagement")); var eventPermissions = eventHubGroup.AddPermission(EventHubPermissions.Events.Default, L("Permission:EventManagement"));
eventPermissions.AddChild(EventHubPermissions.Events.Update, L("Permission:Edit")); eventPermissions.AddChild(EventHubPermissions.Events.Update, L("Permission:Edit"));
var eventRegistrationPermission = eventHubGroup.AddPermission(EventHubPermissions.Events.Registrations.Default, L("Permission:RegistrationManagement"));
eventRegistrationPermission.AddChild(EventHubPermissions.Events.Registrations.AddAttendee, L("Permission:AddAttendee"));
eventRegistrationPermission.AddChild(EventHubPermissions.Events.Registrations.RemoveAttendee, L("Permission:RemoveAttendee"));
} }
private static LocalizableString L(string name) private static LocalizableString L(string name)

7
src/EventHub.Admin.Application.Contracts/Permissions/EventHubPermissions.cs

@ -21,6 +21,13 @@
{ {
public const string Default = GroupName + ".Events"; public const string Default = GroupName + ".Events";
public const string Update = Default + ".Update"; public const string Update = Default + ".Update";
public class Registrations
{
public const string Default = Events.Default + ".Registrations";
public const string AddAttendee = Default + ".AddAttendee";
public const string RemoveAttendee = Default + ".RemoveAttendee";
}
} }
} }
} }

15
src/EventHub.Admin.Application.Contracts/Users/GetUnregisteredUserEventInput.cs

@ -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; }
}
}

12
src/EventHub.Admin.Application.Contracts/Users/IUserAppService.cs

@ -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);
}
}

19
src/EventHub.Admin.Application.Contracts/Users/UserDto.cs

@ -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; }
}
}

6
src/EventHub.Admin.Application/EventHubApplicationAutoMapperProfile.cs

@ -1,12 +1,15 @@
using AutoMapper; using AutoMapper;
using EventHub.Admin.Events; using EventHub.Admin.Events;
using EventHub.Admin.Events.Registrations;
using EventHub.Admin.Organizations; using EventHub.Admin.Organizations;
using EventHub.Admin.Organizations.Memberships; using EventHub.Admin.Organizations.Memberships;
using EventHub.Admin.Users;
using EventHub.Countries; using EventHub.Countries;
using EventHub.Events; using EventHub.Events;
using EventHub.Organizations; using EventHub.Organizations;
using EventHub.Organizations.Memberships; using EventHub.Organizations.Memberships;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Identity;
namespace EventHub.Admin namespace EventHub.Admin
{ {
@ -27,6 +30,9 @@ namespace EventHub.Admin
.Ignore(x => x.CoverImageContent); .Ignore(x => x.CoverImageContent);
CreateMap<Country, CountryLookupDto>(); CreateMap<Country, CountryLookupDto>();
CreateMap<IdentityUser, EventAttendeeDto>();
CreateMap<IdentityUser, UserDto>();
} }
} }
} }

3
src/EventHub.Admin.Application/Events/EventAppService.cs

@ -66,8 +66,7 @@ namespace EventHub.Admin.Events
OrganizationDisplayName = organization.DisplayName, OrganizationDisplayName = organization.DisplayName,
AttendeeCount = (from eventRegistration in eventRegistrationQueryable AttendeeCount = (from eventRegistration in eventRegistrationQueryable
where eventRegistration.EventId == @event.Id where eventRegistration.EventId == @event.Id
group @event by @event.Id into g select @eventRegistration).Count()
select g.Key).Count()
}) })
.WhereIf(!string.IsNullOrWhiteSpace(input.Title), x => x.Title.ToLower().Contains(input.Title.ToLower())) .WhereIf(!string.IsNullOrWhiteSpace(input.Title), x => x.Title.ToLower().Contains(input.Title.ToLower()))
.WhereIf(!string.IsNullOrWhiteSpace(input.OrganizationDisplayName), x => x.OrganizationDisplayName.ToLower().Contains(input.OrganizationDisplayName.ToLower())) .WhereIf(!string.IsNullOrWhiteSpace(input.OrganizationDisplayName), x => x.OrganizationDisplayName.ToLower().Contains(input.OrganizationDisplayName.ToLower()))

86
src/EventHub.Admin.Application/Events/Registrations/EventRegistrationAppService.cs

@ -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);
}
}
}
}

49
src/EventHub.Admin.Application/Users/UserAppService.cs

@ -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));
}
}
}

1
src/EventHub.Admin.HttpApi.Host/Controllers/Events/EventController.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using EventHub.Admin.Events; using EventHub.Admin.Events;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

45
src/EventHub.Admin.HttpApi.Host/Controllers/Events/Registrations/EventRegistrationController.cs

@ -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);
}
}
}

30
src/EventHub.Admin.HttpApi.Host/Controllers/Users/UserController.cs

@ -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);
}
}
}

1
src/EventHub.Admin.Web/Components/UserPicker/UserPicker.razor

@ -0,0 +1 @@
@inherits EventHubComponentBase

160
src/EventHub.Admin.Web/Pages/AttendeeDetail.razor

@ -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>

170
src/EventHub.Admin.Web/Pages/AttendeeDetail.razor.cs

@ -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;
}
}
}

6
src/EventHub.Admin.Web/Pages/EventManagement.razor

@ -6,6 +6,7 @@
@inherits EventHubComponentBase @inherits EventHubComponentBase
@attribute [Authorize(EventHubPermissions.Events.Default)] @attribute [Authorize(EventHubPermissions.Events.Default)]
@inject IEventAppService EventAppService @inject IEventAppService EventAppService
@inject NavigationManager NavigationManager
<Card> <Card>
<CardHeader> <CardHeader>
@ -67,6 +68,11 @@
Clicked="() => OpenEditEventModal(context)" Clicked="() => OpenEditEventModal(context)"
Text="@L["Edit"]"> Text="@L["Edit"]">
</EntityAction> </EntityAction>
<EntityAction TItem="EventInListDto"
RequiredPolicy="@EventHubPermissions.Events.Registrations.Default"
Clicked="@(() => NavigationManager.NavigateTo($"/events/{context.Id}/attendees"))"
Text="@L["Attendees"]">
</EntityAction>
</EntityActions> </EntityActions>
</DisplayTemplate> </DisplayTemplate>
</DataGridEntityActionsColumn> </DataGridEntityActionsColumn>

9
src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -134,6 +134,13 @@
"Capacity": "Capacity", "Capacity": "Capacity",
"EndTime": "End Time", "EndTime": "End Time",
"ChooseCoverImage": "Choose a cover image", "ChooseCoverImage": "Choose a cover image",
"Permission:RegistrationManagement": "Registration Management",
"Permission:AddAttendee": "Add Attendee",
"Permission:RemoveAttendee": "Remove Attendee",
"Attendees": "Attendees",
"AddNewUser": "Add New User",
"AttendeeRemoveConfirmationMessage": "Are you sure you want to remove this item?",
"RemoveUser": "Remove User",
"AddAttendee": "Add Attendee"
} }
} }

Loading…
Cancel
Save