Skip to content

Commit 20d15b8

Browse files
committed
♻️refactor: refactor service interfaces to separate paged and unpaged methods
- Split methods returning paged results and unpaged lists in Event, Organizer, Participant, and Speaker services and interfaces. - Added new methods for unpaged retrieval and renamed paged methods for clarity. - This improves API clarity and flexibility for consumers.
1 parent e666fe4 commit 20d15b8

8 files changed

Lines changed: 39 additions & 12 deletions

File tree

EventFlow.Application/Services/EventService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ public class EventService(IEventRepository repository, IMapper mapper) : IEventS
1313
mapper.Map<EventDTO>(entity);
1414
}
1515

16-
public async Task<PagedResult<EventDTO>> GetAllEventsAsync(QueryParameters queryParameters)
16+
public async Task<List<EventDTO>> GetAllEventsAsync()
1717
{
18-
var pagedEvents = await repository.GetAllEventsAsync(queryParameters);
18+
var events = await repository.GetAllEventsAsync();
19+
return mapper.Map<List<EventDTO>>(events);
20+
}
21+
22+
public async Task<PagedResult<EventDTO>> GetAllPagedEventsAsync(QueryParameters queryParameters)
23+
{
24+
var pagedEvents = await repository.GetAllPagedEventsAsync(queryParameters);
1925

2026
var eventDtos = mapper.Map<List<EventDTO>>(pagedEvents.Items);
2127

EventFlow.Application/Services/OrganizerService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ public class OrganizerService(IOrganizerRepository repository, IEventRepository
1212
mapper.Map<OrganizerDTO>(entity);
1313
}
1414

15-
public async Task<PagedResult<OrganizerDTO>> GetAllOrganizersAsync(QueryParameters queryParameters)
15+
public async Task<List<OrganizerDTO>> GetAllOrganizersAsync()
1616
{
17-
var pagedOrganizers = await repository.GetAllOrganizersAsync(queryParameters);
17+
var organizers = await repository.GetAllOrganizersAsync();
18+
return mapper.Map<List<OrganizerDTO>>(organizers);
19+
}
20+
21+
public async Task<PagedResult<OrganizerDTO>> GetAllPagedOrganizersAsync(QueryParameters queryParameters)
22+
{
23+
var pagedOrganizers = await repository.GetAllPagedOrganizersAsync(queryParameters);
1824

1925
var organizerDtos = mapper.Map<List<OrganizerDTO>>(pagedOrganizers.Items);
2026

EventFlow.Application/Services/ParticipantService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class ParticipantService(IParticipantRepository repository, IEventReposit
1111
null : mapper.Map<ParticipantDTO>(entity);
1212
}
1313

14-
public async Task<PagedResult<ParticipantDTO>> GetAllParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters)
14+
public async Task<PagedResult<ParticipantDTO>> GetAllPagedParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters)
1515
{
16-
var pagedParticipants = await repository.GetAllParticipantsByEventIdAsync(eventId, queryParameters);
16+
var pagedParticipants = await repository.GetAllPagedParticipantsByEventIdAsync(eventId, queryParameters);
1717

1818
var participantDtos = mapper.Map<List<ParticipantDTO>>(pagedParticipants.Items);
1919

@@ -71,4 +71,10 @@ public async Task<bool> DeleteAsync(int id)
7171
var deleted = await repository.DeleteAsync(id);
7272
return deleted > 0;
7373
}
74+
75+
public async Task<List<ParticipantDTO>> GetAllParticipantsWithEventsAsync()
76+
{
77+
var allParticipants = await repository.GetAllParticipantsWithEventsAsync();
78+
return mapper.Map<List<ParticipantDTO>>(allParticipants);
79+
}
7480
}

EventFlow.Application/Services/SpeakerService.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ public class SpeakerService(ISpeakerRepository repository, IEventRepository even
1212
mapper.Map<SpeakerDTO>(entity);
1313
}
1414

15+
public async Task<List<SpeakerDTO>> GetAllSpeakersAsync()
16+
{
17+
var speakers = await repository.GetAllSpeakersAsync();
18+
return mapper.Map<List<SpeakerDTO>>(speakers);
19+
}
1520

16-
public async Task<PagedResult<SpeakerDTO>> GetAllSpeakersAsync(QueryParameters queryParameters)
21+
public async Task<PagedResult<SpeakerDTO>> GetAllPagedSpeakersAsync(QueryParameters queryParameters)
1722
{
18-
var pagedSpeakers = await repository.GetAllSpeakersAsync(queryParameters);
23+
var pagedSpeakers = await repository.GetAllPagedSpeakersAsync(queryParameters);
1924

2025
var speakerDtos = mapper.Map<List<SpeakerDTO>>(pagedSpeakers.Items);
2126

EventFlow.Core/Services/Interfaces/IEventService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
public interface IEventService
44
{
55
Task<EventDTO?> GetByIdAsync(int id);
6-
Task<PagedResult<EventDTO>> GetAllEventsAsync(QueryParameters queryParameters);
6+
Task<List<EventDTO>> GetAllEventsAsync();
7+
Task<PagedResult<EventDTO>> GetAllPagedEventsAsync(QueryParameters queryParameters);
78
Task<Event?> CreateAsync(EventCommand command);
89
Task<EventDTO?> UpdateAsync(int id, EventCommand command);
910
Task<bool> DeleteAsync(int id);

EventFlow.Core/Services/Interfaces/IOrganizerService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
public interface IOrganizerService
44
{
55
Task<OrganizerDTO?> GetByIdAsync(int id);
6-
Task<PagedResult<OrganizerDTO>> GetAllOrganizersAsync(QueryParameters queryParameters);
6+
Task<List<OrganizerDTO>> GetAllOrganizersAsync();
7+
Task<PagedResult<OrganizerDTO>> GetAllPagedOrganizersAsync(QueryParameters queryParameters);
78
Task<Organizer?> CreateAsync(OrganizerCommand command);
89
Task<bool> RegisterToEventAsync(int eventId, int organizerId);
910
Task<OrganizerDTO?> UpdateAsync(int id, OrganizerCommand command);

EventFlow.Core/Services/Interfaces/IParticipantService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
public interface IParticipantService
44
{
55
Task<ParticipantDTO?> GetByIdAsync(int id);
6-
Task<PagedResult<ParticipantDTO>> GetAllParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters);
6+
Task<PagedResult<ParticipantDTO>> GetAllPagedParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters);
77
Task<Participant?> CreateAsync(ParticipantCommand command);
88
Task<bool> RegisterToEventAsync(int eventId, int participantId);
99
Task<ParticipantDTO?> UpdateAsync(int id, ParticipantCommand command);
10+
Task<List<ParticipantDTO>> GetAllParticipantsWithEventsAsync();
1011
Task<bool> DeleteAsync(int id);
1112
}

EventFlow.Core/Services/Interfaces/ISpeakerService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
public interface ISpeakerService
44
{
55
Task<SpeakerDTO?> GetByIdAsync(int id);
6-
Task<PagedResult<SpeakerDTO>> GetAllSpeakersAsync(QueryParameters queryParameters);
6+
Task<List<SpeakerDTO>> GetAllSpeakersAsync();
7+
Task<PagedResult<SpeakerDTO>> GetAllPagedSpeakersAsync(QueryParameters queryParameters);
78
Task<Speaker?> CreateAsync(SpeakerCommand command);
89
Task<bool> RegisterToEventAsync(int eventId, int speakerId);
910
Task<SpeakerDTO?> UpdateAsync(int id, SpeakerCommand command);

0 commit comments

Comments
 (0)