LapTimesDTO

This commit is contained in:
ntr committed 2023-08-30 12:05:55 +10:00
1 parent 361e76cc43
commit 7d083a6cf7
3 files changed
+24 -7

No files matched your search

+6 -4
View File
@@ -21,6 +21,7 @@ public class LapService {
string _mapName;
PlayerData _player;
PbDTO _pb;
PbDTO _lr;
public Lap PB;
@@ -50,13 +51,14 @@ public class LapService {
}
}
PbDTO SetPb(string json) {
PbDTO dto = JsonConvert.DeserializeObject<PbDTO>(json);
_pb = dto;
LapTimesDTO SetPb(string json) {
LapTimesDTO dto = JsonConvert.DeserializeObject<LapTimesDTO>(json);
_pb = dto.Pb;
_lr = dto.LapRecord;
PB = new Lap {
Map = _pb.Map,
Sectors = dto.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
Sectors = _pb.Sectors.Select((d, i) => new SectorTime { Sector = i + 1, Seconds = d }).ToList(),
};
return dto;
+13 -3
View File
@@ -17,12 +17,22 @@ public class PbController : ControllerBase {
}
[HttpGet()]
public PbDTO Pb(Guid userId, string mapName) {
public LapTimesDTO Pb(Guid userId, string mapName) {
_logger.LogInformation($"{userId} {mapName}");
return _db.PbDTO
PbDTO pb = _db.PbDTO
.Where(pb => pb.UserId == userId)
.Where(pb => pb.Map == mapName)
.Single();
.SingleOrDefault();
PbDTO lapRecord = _db.PbDTO
.Where(pb => pb.Map == mapName)
.OrderBy(pb => pb.Position)
.FirstOrDefault();
return new LapTimesDTO {
Pb = pb,
LapRecord = lapRecord,
};
}
}
+5
View File
@@ -22,4 +22,9 @@ namespace SpaceRace.Shared {
public int Completions { get; set; }
public int Position { get; set; }
}
public class LapTimesDTO {
public PbDTO Pb { get; set; }
public PbDTO LapRecord { get; set; }
}
}