Merge pull request #84 from astro/transactionize
Handler.Buy: transactionize postBuyR runDB
This commit is contained in:
commit
54f3b0d89e
1 changed files with 3 additions and 2 deletions
|
@ -51,8 +51,9 @@ postBuyR uId bId = do
|
||||||
else do
|
else do
|
||||||
let price = quant * (beveragePrice bev)
|
let price = quant * (beveragePrice bev)
|
||||||
let sw = price > (userBalance user)
|
let sw = price > (userBalance user)
|
||||||
runDB $ update uId [UserBalance -=. price]
|
runDB $ do
|
||||||
runDB $ update bId [BeverageAmount -=. quant]
|
update uId [UserBalance -=. price]
|
||||||
|
update bId [BeverageAmount -=. quant]
|
||||||
checkAlert bId
|
checkAlert bId
|
||||||
master <- getYesod
|
master <- getYesod
|
||||||
liftIO $ notifyUser user bev price master
|
liftIO $ notifyUser user bev price master
|
||||||
|
|
Loading…
Reference in a new issue