Make balance db update async
This commit is contained in:
parent
dfcfd3b5cb
commit
6c1aa7a445
|
@ -117,7 +117,7 @@ public class CardController : Controller {
|
||||||
[SwaggerResponseExample(200, typeof(UserUpdatedExample))]
|
[SwaggerResponseExample(200, typeof(UserUpdatedExample))]
|
||||||
[SwaggerResponseExample(404, typeof(ErrorUnknownCardExample))]
|
[SwaggerResponseExample(404, typeof(ErrorUnknownCardExample))]
|
||||||
[Route("/api/card/{card}/balance")]
|
[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();
|
var db = new DatabaseContext();
|
||||||
if (db.Cards.Any(p => p.Id == card)) {
|
if (db.Cards.Any(p => p.Id == card)) {
|
||||||
var user = db.Cards.Include(p => p.User).First(p => p.Id == card).User;
|
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) {
|
if (dbCard.Type != newType) {
|
||||||
dbCard.Type = newType;
|
dbCard.Type = newType;
|
||||||
db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(new UserResponse(user));
|
return Ok(new UserResponse(user));
|
||||||
|
|
Loading…
Reference in a new issue