diff --git a/WebApp/DTOs/EventSearchDto.cs b/WebApp/DTOs/EventSearchDto.cs index 712d201..cf84c3a 100644 --- a/WebApp/DTOs/EventSearchDto.cs +++ b/WebApp/DTOs/EventSearchDto.cs @@ -9,7 +9,9 @@ public record class EventSearchDto int? OrganisationId, string? TitleOrDescription, string? Location, - DateTime? EventDate, + DateTime? EventDateFrom, // zakres daty od + DateTime? EventDateTo, // zakres daty do ICollection? EventSkills, // obecnie nie dotyczy ICollection? EventRegistrations // obecnie nie dotyczy + ); diff --git a/WebApp/Endpoints/EventsEndpoints.cs b/WebApp/Endpoints/EventsEndpoints.cs index 39f2966..6ece587 100644 --- a/WebApp/Endpoints/EventsEndpoints.cs +++ b/WebApp/Endpoints/EventsEndpoints.cs @@ -155,13 +155,19 @@ namespace WebApp.Endpoints { // Uzyskaj organizację z tokenu + var sort = httpContext.Request.Query["sort"].ToString(); Token? token = await guhf.GetTokenFromHTTPContext(httpContext); Organisation? org = await guhf.GetOrganisationFromToken(token); List SearchResults = []; - List AllEvents = await dbContext.Events.ToListAsync(); - AllEvents.Reverse(); // aby wyświetlało od najnowszych wydarzeń + + List AllEvents = await dbContext.Events.ToListAsync(); + if (sort is null || sort.ToUpper() != "ASC") + { + AllEvents.Reverse(); // aby wyświetlało od najnowszych wydarzeń + + } foreach(Event e in AllEvents) { @@ -181,6 +187,19 @@ namespace WebApp.Endpoints if (!TitleMatch && !DescMatch) matchFound = false; } + + //Zakres dat do wyszukiwania + if(query.EventDateFrom is not null) + { + if (e.EventDate < query.EventDateFrom) matchFound = false; + + } + if(query.EventDateTo is not null) + { + if (e.EventDate > query.EventDateTo) matchFound = false; + } + + // ... // Jeśli Event jest tym, czego szuka użytkownik,