aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller/Income.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Controller/Income.hs')
-rw-r--r--src/server/Controller/Income.hs48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/server/Controller/Income.hs b/src/server/Controller/Income.hs
deleted file mode 100644
index 148b713..0000000
--- a/src/server/Controller/Income.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Controller.Income
- ( create
- , editOwn
- , deleteOwn
- ) where
-
-import Control.Monad.IO.Class (liftIO)
-import Network.HTTP.Types.Status (ok200, badRequest400)
-import qualified Data.Text.Lazy as TL
-import Web.Scotty
-
-import qualified Common.Message as Message
-import qualified Common.Message.Key as Key
-import Common.Model (CreateIncome(..), EditIncome(..), IncomeId, User(..))
-
-import Json (jsonId)
-import qualified Model.Income as Income
-import qualified Model.Query as Query
-import qualified Secure
-
-create :: CreateIncome -> ActionM ()
-create (CreateIncome date amount) =
- Secure.loggedAction (\user ->
- (liftIO . Query.run $ Income.create (_user_id user) date amount) >>= jsonId
- )
-
-editOwn :: EditIncome -> ActionM ()
-editOwn (EditIncome incomeId date amount) =
- Secure.loggedAction (\user -> do
- updated <- liftIO . Query.run $ Income.editOwn (_user_id user) incomeId date amount
- if updated
- then status ok200
- else status badRequest400
- )
-
-deleteOwn :: IncomeId -> ActionM ()
-deleteOwn incomeId =
- Secure.loggedAction (\user -> do
- deleted <- liftIO . Query.run $ Income.deleteOwn user incomeId
- if deleted
- then
- status ok200
- else do
- status badRequest400
- text . TL.fromStrict $ Message.get Key.Income_NotDeleted
- )