LapTimesDTO
This commit is contained in:
1 parent
6450d3b093
commit
900ee4412d
3 files changed
+24
-7
No files matched your search
@@ -21,6 +21,7 @@ public class LapService {
|
|||||||
string _mapName;
|
string _mapName;
|
||||||
PlayerData _player;
|
PlayerData _player;
|
||||||
PbDTO _pb;
|
PbDTO _pb;
|
||||||
|
PbDTO _lr;
|
||||||
|
|
||||||
public Lap PB;
|
public Lap PB;
|
||||||
|
|
||||||
@@ -50,13 +51,14 @@ public class LapService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PbDTO SetPb(string json) {
|
LapTimesDTO SetPb(string json) {
|
||||||
PbDTO dto = JsonConvert.DeserializeObject<PbDTO>(json);
|
LapTimesDTO dto = JsonConvert.DeserializeObject<LapTimesDTO>(json);
|
||||||
_pb = dto;
|
_pb = dto.Pb;
|
||||||
|
_lr = dto.LapRecord;
|
||||||
|
|
||||||
PB = new Lap {
|
PB = new Lap {
|
||||||
Map = _pb.Map,
|
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;
|
return dto;
|
||||||
|
|||||||
@@ -17,12 +17,22 @@ public class PbController : ControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet()]
|
[HttpGet()]
|
||||||
public PbDTO Pb(Guid userId, string mapName) {
|
public LapTimesDTO Pb(Guid userId, string mapName) {
|
||||||
_logger.LogInformation($"{userId} {mapName}");
|
_logger.LogInformation($"{userId} {mapName}");
|
||||||
|
|
||||||
return _db.PbDTO
|
PbDTO pb = _db.PbDTO
|
||||||
.Where(pb => pb.UserId == userId)
|
.Where(pb => pb.UserId == userId)
|
||||||
.Where(pb => pb.Map == mapName)
|
.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,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,4 +22,9 @@ namespace SpaceRace.Shared {
|
|||||||
public int Completions { get; set; }
|
public int Completions { get; set; }
|
||||||
public int Position { get; set; }
|
public int Position { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LapTimesDTO {
|
||||||
|
public PbDTO Pb { get; set; }
|
||||||
|
public PbDTO LapRecord { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user