server post wip
This commit is contained in:
1 parent
f6cd8d42ce
commit
d2277f4e0f
13 files changed
+239
-30
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Server.Models;
|
||||
|
||||
namespace Server.Controllers;
|
||||
@@ -22,18 +21,44 @@ public class LapController : ControllerBase {
|
||||
UserId = c.UserId,
|
||||
Map = c.Map,
|
||||
Time = c.Time,
|
||||
Date = c.Date,
|
||||
Created = c.Created,
|
||||
});
|
||||
}
|
||||
|
||||
// [HttpGet()]
|
||||
// public LapStorageDTO UserLaps(Guid userId, string mapName) {
|
||||
// List<Lap> laps = _db.Laps
|
||||
// .Where(l => l.Id == userId)
|
||||
// .Where(l => l.Map == mapName);
|
||||
|
||||
// int completions = _db.Laps
|
||||
// .Where(l => l.Map == mapName)
|
||||
// .Count();
|
||||
|
||||
// int position = _db.Database<Laps>.sql("""
|
||||
// SELECT
|
||||
// """);
|
||||
|
||||
// return new LapStorageDTO {
|
||||
// Map = mapName,
|
||||
// Laps = laps,
|
||||
// public int Completions { get; set; }
|
||||
// public int Position { get; set; }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<Lap> Post(LapDTO dto) {
|
||||
Lap existing = _db.Laps
|
||||
.SingleOrDefault(l => l.UserId == dto.UserId && l.Map == dto.Map);
|
||||
|
||||
Lap v = new Lap {
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = Guid.NewGuid(),
|
||||
UserId = dto.UserId,
|
||||
Map = dto.Map,
|
||||
Time = dto.Time,
|
||||
Date = DateTimeOffset.UtcNow,
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
_db.Laps.Add(v);
|
||||
|
||||
Reference in new issue
Block a user