Fixed errcheck linter complaints

This commit is contained in:
2019-06-05 15:45:54 +09:00
parent 190a85fe08
commit 940e949a30
15 changed files with 112 additions and 33 deletions

View File

@ -45,14 +45,20 @@ func BuyItem(ctx aero.Context) error {
return ctx.Error(http.StatusBadRequest, "Not enough gems. You need to charge up your balance before you can buy this item.")
}
user.Balance -= totalPrice
user.Save()
// Add item to user inventory
inventory := user.Inventory()
inventory.AddItem(itemID, uint(quantity))
err = inventory.AddItem(itemID, uint(quantity))
if err != nil {
return ctx.Error(http.StatusBadRequest, err)
}
inventory.Save()
// Deduct balance
user.Balance -= totalPrice
user.Save()
// Save purchase
purchase := arn.NewPurchase(user.ID, itemID, quantity, int(item.Price), "gem")
purchase.Save()