Skip to content

Commit

Permalink
Update EventService.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
bilimig committed Jun 23, 2024
1 parent 0c464c8 commit b7dfb07
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Server/ReasnAPI/ReasnAPI/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,22 @@ public IEnumerable<EventResponse> GetUserEvents(string username)
throw new NotFoundException("User not found");
}

var userEvents = context.Participants
var userEventIds = context.Participants
.Where(p => p.UserId == user.Id)
.Select(p => p.Event)
.Include(e => e.Parameters)
.Include(e => e.Tags)
.Include(e => e.Address)
.Include(e => e.Organizer);

.Select(p => p.EventId)
.ToList();

var userEvents = context.Events
.Where(e => userEventIds.Contains(e.Id))
.Include(e => e.Parameters)
.Include(e => e.Tags)
.Include(e => e.Address)
.Include(e => e.Organizer)
.ToList();




var eventsResponses = new List<EventResponse>();

foreach (var thisEvent in userEvents)
Expand All @@ -326,6 +334,8 @@ public IEnumerable<EventResponse> GetUserEvents(string username)
eventsResponses.Add(eventResponse);
}



return eventsResponses.AsEnumerable();
}

Expand Down

0 comments on commit b7dfb07

Please sign in to comment.