fix Bewilderbeast Alpha Rally

- implemented UseInventory API endpoint
This commit is contained in:
Robert Paciorek 2023-08-09 18:36:47 +00:00 committed by Spirtix
parent 794b8487f1
commit 947b2cb4a3

View File

@ -217,6 +217,22 @@ public class ContentController : Controller {
return Ok(response); return Ok(response);
} }
[HttpPost]
[Produces("application/xml")]
[Route("ContentWebService.asmx/UseInventory")]
public IActionResult UseInventory([FromForm] string apiToken, [FromForm] int userInventoryId, [FromForm] int numberOfUses) {
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == userInventoryId);
if (item is null)
return Ok(false);
if (item.Quantity < numberOfUses)
return Ok(false);
item.Quantity -= numberOfUses;
ctx.SaveChanges();
return Ok(true);
}
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]