Initial Commit

Inital Commit of Code base, nothing tested.
This commit is contained in:
Mario Steele 2025-07-19 04:02:09 -05:00
commit 0144221712
31 changed files with 1304 additions and 0 deletions

View file

@ -0,0 +1,35 @@
using FreeTubeSync.Model;
namespace FreeTubeSync.EndPoints;
public static class ProfileEndpoint
{
public static void MapProfileEndpoints(this WebApplication app)
{
var group = app.MapGroup("profile");
group.MapGet("/", async (IRepository<Profile> repository, CancellationToken ct) =>
{
var results = await repository.GetAllAsync(ct);
return Results.Ok(results);
});
group.MapPost("/", async (IRepository<Profile> repository, CancellationToken ct, Profile profile) =>
{
var res = await repository.GetByIdAsync(profile._id, ct);
if (res == null)
await repository.AddAsync(profile, ct);
else
await repository.UpdateAsync(profile, ct);
return Results.Ok();
});
group.MapDelete("/{id}", async (IRepository<Profile> repository, CancellationToken ct, string id) =>
{
var result = await repository.GetByIdAsync(id, ct);
if (result == null) return Results.NotFound();
await repository.DeleteAsync(result, ct);
return Results.Ok();
});
}
}