Make balance db update async

This commit is contained in:
Laura Hausmann 2023-05-18 23:50:01 +02:00
parent dfcfd3b5cb
commit 6c1aa7a445
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -117,7 +117,7 @@ public class CardController : Controller {
[SwaggerResponseExample(200, typeof(UserUpdatedExample))]
[SwaggerResponseExample(404, typeof(ErrorUnknownCardExample))]
[Route("/api/card/{card}/balance")]
public IActionResult Balance(string card, [FromQuery] string? reader) {
public async Task<IActionResult> Balance(string card, [FromQuery] string? reader) {
var db = new DatabaseContext();
if (db.Cards.Any(p => p.Id == card)) {
var user = db.Cards.Include(p => p.User).First(p => p.Id == card).User;
@ -127,7 +127,7 @@ public class CardController : Controller {
if (dbCard.Type != newType) {
dbCard.Type = newType;
db.SaveChangesAsync();
await db.SaveChangesAsync();
}
return Ok(new UserResponse(user));