Initial Commit
Inital Commit of Code base, nothing tested.
This commit is contained in:
commit
0144221712
31 changed files with 1304 additions and 0 deletions
36
FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs
Normal file
36
FreeTubeSync/EndPoints/SearchHistoryEndpoint.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using FreeTubeSync.Model;
|
||||
|
||||
namespace FreeTubeSync.EndPoints;
|
||||
|
||||
public static class SearchHistoryEndpoint
|
||||
{
|
||||
public static void MapSearchHistoryEndpoints(this WebApplication app)
|
||||
{
|
||||
var group = app.MapGroup("searchHistory");
|
||||
|
||||
group.MapGet("/", async (IRepository<History> repository, CancellationToken ct) =>
|
||||
{
|
||||
var result = await repository.GetAllAsync(ct);
|
||||
return Results.Ok(result);
|
||||
});
|
||||
|
||||
group.MapPost("/", async (IRepository<History> repository, CancellationToken ct, History history) =>
|
||||
{
|
||||
var result = await repository.GetByIdAsync(history._id, ct);
|
||||
if (result != null)
|
||||
await repository.UpdateAsync(history, ct);
|
||||
else
|
||||
await repository.AddAsync(history, ct);
|
||||
return Results.Ok();
|
||||
});
|
||||
|
||||
group.MapDelete("/{id}", async (IRepository<History> 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();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue