|
|
|
@ -1,7 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EventHub.Users; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
@ -12,15 +15,18 @@ namespace EventHub.Events.Registrations |
|
|
|
private readonly EventRegistrationManager _eventRegistrationManager; |
|
|
|
private readonly IRepository<AppUser, Guid> _userRepository; |
|
|
|
private readonly IRepository<Event, Guid> _eventRepository; |
|
|
|
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository; |
|
|
|
|
|
|
|
public EventRegistrationAppService( |
|
|
|
EventRegistrationManager eventRegistrationManager, |
|
|
|
IRepository<AppUser, Guid> userRepository, |
|
|
|
IRepository<Event, Guid> eventRepository) |
|
|
|
IRepository<Event, Guid> eventRepository, |
|
|
|
IRepository<EventRegistration, Guid> eventRegistrationRepository) |
|
|
|
{ |
|
|
|
_eventRegistrationManager = eventRegistrationManager; |
|
|
|
_userRepository = userRepository; |
|
|
|
_eventRepository = eventRepository; |
|
|
|
_eventRegistrationRepository = eventRegistrationRepository; |
|
|
|
} |
|
|
|
|
|
|
|
[Authorize] |
|
|
|
@ -49,5 +55,25 @@ namespace EventHub.Events.Registrations |
|
|
|
await _userRepository.GetAsync(CurrentUser.GetId()) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
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<AppUser>, List<EventAttendeeDto>>(users) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|