-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to .NET 9 and move to Minimal API
- Loading branch information
Showing
20 changed files
with
526 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace FiMAdminApi.Data.Enums; | ||
|
||
public enum DataSources | ||
{ | ||
FrcEvents, | ||
BlueAlliance, | ||
OrangeAlliance | ||
} |
3 changes: 2 additions & 1 deletion
3
FiMAdminApi.Data/Models/GlobalRole.cs → FiMAdminApi.Data/Enums/GlobalRole.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.ComponentModel; | ||
|
||
namespace FiMAdminApi.Data.Models; | ||
|
||
public class Event | ||
{ | ||
public Guid Id { get; set; } | ||
public required int SeasonId { get; set; } | ||
public required string Key { get; set; } | ||
public string? Code { get; set; } | ||
public required string Name { get; set; } | ||
public string? SyncSource { get; set; } | ||
public required bool IsOfficial { get; set; } | ||
public int? TruckRouteId { get; set; } | ||
public TruckRoute? TruckRoute { get; set; } | ||
public required DateTimeOffset StartTime { get; set; } | ||
public required DateTimeOffset EndTime { get; set; } | ||
public DateTimeOffset? SyncAsOf { get; set; } | ||
public required string Status { get; set; } = "NotStarted"; | ||
|
||
// Relations | ||
[Description("Note: This object may not be populated in some endpoints.")] | ||
public Season? Season { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
using Supabase.Postgrest.Attributes; | ||
using Supabase.Postgrest.Models; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace FiMAdminApi.Data.Models; | ||
|
||
[Table("levels")] | ||
public class Level : BaseModel | ||
public class Level | ||
{ | ||
[PrimaryKey("id")] | ||
[Key] | ||
public int Id { get; set; } | ||
[Column("name")] | ||
public string Name { get; set; } | ||
public required string Name { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace FiMAdminApi.Data.Models; | ||
|
||
public class Season | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
public required int LevelId { get; set; } | ||
public Level? Level { get; set; } | ||
public required string Name { get; set; } | ||
public required DateTime StartTime { get; set; } | ||
public required DateTime EndTime { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace FiMAdminApi.Data.Models; | ||
|
||
public class TruckRoute | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using FiMAdminApi.Data.Enums; | ||
|
||
namespace FiMAdminApi.Data.Models; | ||
|
||
public class User | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace FiMAdminApi.Clients; | ||
|
||
public static class ClientsStartupExtensions | ||
{ | ||
public static void AddClients(this IServiceCollection services) | ||
{ | ||
services.AddHttpClient("FrcEvents"); | ||
services.AddKeyedScoped<IDataClient, FrcEventsDataClient>("FrcEvents"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Asp.Versioning.Builder; | ||
using FiMAdminApi.Data.Enums; | ||
using FiMAdminApi.Services; | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace FiMAdminApi.Clients.Endpoints; | ||
|
||
public static class EventsCreateEndpoints | ||
{ | ||
public static WebApplication RegisterEventsCreateEndpoints(this WebApplication app, ApiVersionSet vs) | ||
{ | ||
var eventsCreateGroup = app.MapGroup("/api/v{apiVersion:apiVersion}/users") | ||
.WithApiVersionSet(vs).HasApiVersion(1).WithTags("Events - Create") | ||
.RequireAuthorization(nameof(GlobalRole.Events_Create)); | ||
|
||
eventsCreateGroup.MapPost("sync-source", SyncSource) | ||
.WithSummary("Create from Sync Source") | ||
.WithDescription( | ||
"Will return OK if operation is fully successful, or BadRequest if it contains any errors"); | ||
|
||
return app; | ||
} | ||
|
||
private static async Task<Results<Ok<UpsertEventsService.UpsertEventsResponse>, BadRequest<UpsertEventsService.UpsertEventsResponse>>> SyncSource( | ||
[FromBody] UpsertEventsService.UpsertFromDataSourceRequest request, | ||
[FromServices] UpsertEventsService service) | ||
{ | ||
var resp = await service.UpsertFromDataSource(request); | ||
|
||
return resp.Errors.Count == 0 ? TypedResults.Ok(resp) : TypedResults.BadRequest(resp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.