Handler.Buy: transactionize postBuyR runDB

This commit is contained in:
Astro 2016-01-24 00:42:58 +01:00
parent 4c2c09bdfa
commit 18fa53c696

View file

@ -51,8 +51,9 @@ postBuyR uId bId = do
else do
let price = quant * (beveragePrice bev)
let sw = price > (userBalance user)
runDB $ update uId [UserBalance -=. price]
runDB $ update bId [BeverageAmount -=. quant]
runDB $ do
update uId [UserBalance -=. price]
update bId [BeverageAmount -=. quant]
checkAlert bId
master <- getYesod
liftIO $ notifyUser user bev price master