forked from SoDOff-Project/sodoff
fix Bewilderbeast Alpha Rally
- implemented UseInventory API endpoint
This commit is contained in:
parent
794b8487f1
commit
947b2cb4a3
@ -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")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user