blob: 51861d394c0be5cdc6ef2442210b9f47abee9852 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
{-# LANGUAGE OverloadedStrings #-}
module Controller.Income
( getIncomes
, setIncome
) where
import Web.Scotty
import Control.Monad.IO.Class (liftIO)
import Database.Persist
import qualified Secure
import Json (jsonId)
import Model.Database
import qualified Model.Income as Income
getIncomes :: ActionM ()
getIncomes =
Secure.loggedAction (\_ ->
(liftIO $ map Income.getJsonIncome <$> runDb Income.getIncomes) >>= json
)
setIncome :: Int -> ActionM ()
setIncome amount =
Secure.loggedAction (\user -> do
(liftIO . runDb $ Income.setIncome (entityKey user) amount) >>= jsonId
)
|