mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Add search date range
This commit is contained in:
@@ -9,7 +9,9 @@ public record class EventSearchDto
|
|||||||
int? OrganisationId,
|
int? OrganisationId,
|
||||||
string? TitleOrDescription,
|
string? TitleOrDescription,
|
||||||
string? Location,
|
string? Location,
|
||||||
DateTime? EventDate,
|
DateTime? EventDateFrom, // zakres daty od
|
||||||
|
DateTime? EventDateTo, // zakres daty do
|
||||||
ICollection<EventSkill>? EventSkills, // obecnie nie dotyczy
|
ICollection<EventSkill>? EventSkills, // obecnie nie dotyczy
|
||||||
ICollection<EventRegistration>? EventRegistrations // obecnie nie dotyczy
|
ICollection<EventRegistration>? EventRegistrations // obecnie nie dotyczy
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -155,13 +155,19 @@ namespace WebApp.Endpoints
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Uzyskaj organizację z tokenu
|
// Uzyskaj organizację z tokenu
|
||||||
|
var sort = httpContext.Request.Query["sort"].ToString();
|
||||||
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||||
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
Organisation? org = await guhf.GetOrganisationFromToken(token);
|
||||||
List<EventSummaryDto> SearchResults = [];
|
List<EventSummaryDto> SearchResults = [];
|
||||||
|
|
||||||
List<Event> AllEvents = await dbContext.Events.ToListAsync();
|
|
||||||
AllEvents.Reverse(); // aby wyświetlało od najnowszych wydarzeń
|
|
||||||
|
|
||||||
|
|
||||||
|
List<Event> 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)
|
foreach(Event e in AllEvents)
|
||||||
{
|
{
|
||||||
@@ -181,6 +187,19 @@ namespace WebApp.Endpoints
|
|||||||
if (!TitleMatch && !DescMatch) matchFound = false;
|
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,
|
// Jeśli Event jest tym, czego szuka użytkownik,
|
||||||
|
|||||||
Reference in New Issue
Block a user