feat: moved to C# thanks to deepseek
This commit is contained in:
1 parent
ab81a1c4be
commit
29ed46aa7f
34 files changed
+1583
-14
No files matched your search
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Phenix.Services;
|
||||
|
||||
namespace Phenix.Controllers;
|
||||
|
||||
[Route("/api")]
|
||||
public class ApiController : Controller
|
||||
{
|
||||
private readonly IGameService _games;
|
||||
|
||||
public ApiController(IGameService games)
|
||||
{
|
||||
_games = games;
|
||||
}
|
||||
|
||||
[HttpGet("results/{year}.json")]
|
||||
public async Task<IActionResult> ResultsJson(int year)
|
||||
{
|
||||
var games = await _games.GetAllGames();
|
||||
var results = games
|
||||
.Where(g => g.Year == year)
|
||||
.Select(g => new Dictionary<string, object?>
|
||||
{
|
||||
["id"] = g.Id,
|
||||
["date"] = g.Date,
|
||||
["time"] = g.Time,
|
||||
["home"] = g.Home,
|
||||
["away"] = g.Away,
|
||||
["year"] = g.Year,
|
||||
[g.Home] = g.HomeScore,
|
||||
[g.Away] = g.AwayScore,
|
||||
["practice"] = g.Practice,
|
||||
["rain"] = g.Rain,
|
||||
});
|
||||
return Json(results);
|
||||
}
|
||||
|
||||
[HttpGet("available-years.json")]
|
||||
public async Task<IActionResult> AvailableYearsJson()
|
||||
{
|
||||
var games = await _games.GetAllGames();
|
||||
var years = games.Select(g => g.Year).Distinct().OrderByDescending(y => y);
|
||||
return Json(years);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user