adding completions
This commit is contained in:
1 parent
a69a376325
commit
8b1b4f8ac6
11 files changed
+210
-20
No files matched your search
@@ -15,7 +15,7 @@ public class CompletionController : ControllerBase {
|
||||
_db = db;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetCompletion")]
|
||||
[HttpGet()]
|
||||
public IEnumerable<CompletionDTO> Get() {
|
||||
return _db.Completions.Select(c => new CompletionDTO {
|
||||
Id = c.Id,
|
||||
@@ -25,4 +25,19 @@ public class CompletionController : ControllerBase {
|
||||
Date = c.Date,
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<Completion> Post(CompletionDTO dto) {
|
||||
Completion v = new Completion {
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = Guid.NewGuid(),
|
||||
Map = dto.Map,
|
||||
Time = dto.Time,
|
||||
Date = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
_db.Completions.Add(v);
|
||||
await _db.SaveChangesAsync();
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user