various bugfixes

This commit is contained in:
ntr committed 2023-08-30 12:36:23 +10:00
1 parent 900ee4412d
commit b7ad479ead
12 files changed
+39 -38

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Data.SqlClient;
using SpaceRace.Shared;
namespace Server.Controllers;
[ApiController]
[Route("[controller]")]
public class LapTimesController : ControllerBase {
private readonly ILogger<LapTimesController> _logger;
private SpaceRaceDbContext _db;
public LapTimesController(ILogger<LapTimesController> logger, SpaceRaceDbContext db) {
_logger = logger;
_db = db;
}
[HttpGet()]
public LapTimesDTO LapTimes(Guid userId, string mapName) {
_logger.LogInformation($"{userId} {mapName}");
PbDTO pb = _db.PbDTO
.Where(pb => pb.UserId == userId)
.Where(pb => pb.Map == mapName)
.SingleOrDefault();
PbDTO lapRecord = _db.PbDTO
.Where(pb => pb.Map == mapName)
.OrderBy(pb => pb.Position)
.FirstOrDefault();
return new LapTimesDTO {
Pb = pb,
LapRecord = lapRecord,
};
}
}