mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Merge branch 'calendar'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Cryptography;
|
||||
@@ -128,7 +128,26 @@ namespace WebApp.Endpoints
|
||||
|
||||
return Results.Json(new { success = true });
|
||||
});
|
||||
group.MapGet("/registered",
|
||||
async (ApplicationDbContext dbContext, HttpContext httpContext, GeneralUseHelpers guhf) =>
|
||||
{
|
||||
Token? token = await guhf.GetTokenFromHTTPContext(httpContext);
|
||||
User? user = await guhf.GetUserFromToken(token);
|
||||
|
||||
if (user is null || user.IsOrganisation)
|
||||
return Results.Json(new { success = false, error_msg = "Unauthorized or organisations cannot register." });
|
||||
|
||||
var events = await dbContext.EventRegistrations
|
||||
.Where(r => r.UserId == user.UserId)
|
||||
.Select(r => new {
|
||||
r.Event.EventId,
|
||||
r.Event.Title,
|
||||
r.Event.EventDate
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Results.Json(events);
|
||||
});
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user