Skip to content

Commit 9fcbd23

Browse files
committed
✨feat: add non-paged list retrieval methods to repositories
- Introduced new methods in repository interfaces and implementations to retrieve all entities as lists without pagination for Event, Organizer, Participant, and Speaker. - Existing paged methods were renamed for clarity, and corresponding changes were made in the infrastructure layer to support these new methods.
1 parent 7c0ead8 commit 9fcbd23

8 files changed

Lines changed: 40 additions & 11 deletions

File tree

EventFlow.Core/Repository/Interfaces/IEventRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public interface IEventRepository
77
Task<int> DeleteAsync(int id);
88
Task<Event?> GetEventByIdAsync(int id);
99
Task<Event?> GetEventWithDetailsByIdAsync(int id);
10-
Task<PagedResult<Event>> GetAllEventsAsync(QueryParameters queryParameters);
10+
Task<List<Event>> GetAllEventsAsync();
11+
Task<PagedResult<Event>> GetAllPagedEventsAsync(QueryParameters queryParameters);
1112
Task<int> EventCountAsync();
1213
}

EventFlow.Core/Repository/Interfaces/IOrganizerRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface IOrganizerRepository
66
Task<Organizer> UpdateAsync(Organizer organizer);
77
Task<int> DeleteAsync(int id);
88
Task<Organizer?> GetOrganizerByIdAsync(int id);
9-
Task<PagedResult<Organizer>> GetAllOrganizersAsync(QueryParameters queryParameters);
9+
Task<List<Organizer>> GetAllOrganizersAsync();
10+
Task<PagedResult<Organizer>> GetAllPagedOrganizersAsync(QueryParameters queryParameters);
1011
Task<int> OrganizerCountAsync();
1112
}

EventFlow.Core/Repository/Interfaces/IParticipantRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface IParticipantRepository
66
Task<Participant> UpdateAsync(Participant participant);
77
Task<int> DeleteAsync(int id);
88
Task<Participant?> GetParticipantByIdAsync(int id);
9-
Task<PagedResult<Participant>> GetAllParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters);
9+
Task<PagedResult<Participant>> GetAllPagedParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters);
10+
Task<List<Participant>> GetAllParticipantsWithEventsAsync();
1011
Task<int> ParticipantCountAsync();
1112
}

EventFlow.Core/Repository/Interfaces/ISpeakerRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ public interface ISpeakerRepository
66
Task<Speaker> UpdateAsync(Speaker speaker);
77
Task<int> DeleteAsync(int id);
88
Task<Speaker?> GetSpeakerByIdAsync(int id);
9-
Task<PagedResult<Speaker>> GetAllSpeakersAsync(QueryParameters queryParameters);
9+
Task<List<Speaker>> GetAllSpeakersAsync();
10+
Task<PagedResult<Speaker>> GetAllPagedSpeakersAsync(QueryParameters queryParameters);
1011
Task AddSpeakerEventAsync(SpeakerEvent speakerEvent);
1112
Task<int> SpeakerCountAsync();
1213
}

EventFlow.Infrastructure/Repository/EventRepository.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ public async Task<int> DeleteAsync(int id)
4747
.FirstOrDefaultAsync(e => e.Id == id);
4848
}
4949

50-
public async Task<PagedResult<Event>> GetAllEventsAsync(QueryParameters queryParameters)
50+
public async Task<List<Event>> GetAllEventsAsync()
51+
{
52+
return await context.Event
53+
.AsNoTracking()
54+
.ToListAsync();
55+
}
56+
57+
public async Task<PagedResult<Event>> GetAllPagedEventsAsync(QueryParameters queryParameters)
5158
{
5259
var query = context.Event
5360
.Include(e => e.Organizer)

EventFlow.Infrastructure/Repository/OrganizerRepository.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ public async Task<int> DeleteAsync(int id)
3636
.FirstOrDefaultAsync(o => o.Id == id);
3737
}
3838

39-
public async Task<PagedResult<Organizer>> GetAllOrganizersAsync(QueryParameters queryParameters)
39+
public async Task<List<Organizer>> GetAllOrganizersAsync()
40+
{
41+
return await context.Organizer
42+
.ToListAsync();
43+
}
44+
45+
public async Task<PagedResult<Organizer>> GetAllPagedOrganizersAsync(QueryParameters queryParameters)
4046
{
4147
var query = context.Organizer
4248
.Include(o => o.Events)

EventFlow.Infrastructure/Repository/ParticipantRepository.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<int> DeleteAsync(int id)
3838
.FirstOrDefaultAsync(p => p.Id == id);
3939
}
4040

41-
public async Task<PagedResult<Participant>> GetAllParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters)
41+
public async Task<PagedResult<Participant>> GetAllPagedParticipantsByEventIdAsync(int eventId, QueryParameters queryParameters)
4242
{
4343
var query = context.Participant
4444
.Where(p => p.Events!.Any(e => e.Id == eventId))
@@ -68,6 +68,14 @@ public async Task<PagedResult<Participant>> GetAllParticipantsByEventIdAsync(int
6868
return new PagedResult<Participant>(items, queryParameters.PageNumber, queryParameters.PageSize, totalCount);
6969
}
7070

71+
public async Task<List<Participant>> GetAllParticipantsWithEventsAsync()
72+
{
73+
return await context.Participant
74+
.Include(p => p.Events)
75+
.AsNoTracking()
76+
.ToListAsync();
77+
}
78+
7179
public async Task<int> ParticipantCountAsync()
7280
{
7381
return await context.Participant.CountAsync();

EventFlow.Infrastructure/Repository/SpeakerRepository.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Microsoft.EntityFrameworkCore;
2-
3-
namespace EventFlow.Infrastructure.Repository;
1+
namespace EventFlow.Infrastructure.Repository;
42

53
public class SpeakerRepository(EventFlowContext context) : ISpeakerRepository
64
{
@@ -37,7 +35,13 @@ public async Task<int> DeleteAsync(int id)
3735
.FirstOrDefaultAsync(s => s.Id == id);
3836
}
3937

40-
public async Task<PagedResult<Speaker>> GetAllSpeakersAsync(QueryParameters queryParameters)
38+
public async Task<List<Speaker>> GetAllSpeakersAsync()
39+
{
40+
return await context.Speaker
41+
.ToListAsync();
42+
}
43+
44+
public async Task<PagedResult<Speaker>> GetAllPagedSpeakersAsync(QueryParameters queryParameters)
4145
{
4246
var query = context.Speaker
4347
.Include(s => s.SpeakerEvents)

0 commit comments

Comments
 (0)