Skip to content

Commit

Permalink
updated events controller
Browse files Browse the repository at this point in the history
added returnign empty list if image for event is not found, filtered get all events to not return waiting for aproval events
  • Loading branch information
bilimig committed Jun 23, 2024
1 parent 7807e0e commit 51af7a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Server/ReasnAPI/ReasnAPI/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public List<string> GetEventImages(string slug)

public IEnumerable<EventResponse> GetAllEvents()
{
var events = context.Events.Include(e => e.Parameters).Include(e => e.Tags).Include(e => e.Address).Include(e => e.Organizer).ToList();
var events = context.Events.Include(e => e.Parameters).Include(e => e.Tags).Include(e => e.Address).Include(e => e.Organizer).Where(e => e.Status != EventStatus.PendingApproval).ToList();
var eventsResponses = new List<EventResponse>();
foreach (var thisEvent in events )
{
Expand Down
3 changes: 1 addition & 2 deletions Server/ReasnAPI/ReasnAPI/Services/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public IEnumerable<ImageDto> GetImagesByFilter(Expression<Func<Image, bool>> fil
.ToDtoList()
.AsEnumerable();
}

public IEnumerable<ImageDto> GetImagesByEventId(int eventId)
{
var images = context.Images
Expand All @@ -213,7 +212,7 @@ public IEnumerable<ImageDto> GetImagesByEventId(int eventId)

if (!images.Any())
{
throw new NotFoundException("Images not found");
return Enumerable.Empty<ImageDto>();
}

var imageDtos = images.ToDtoList().AsEnumerable();
Expand Down

0 comments on commit 51af7a5

Please sign in to comment.