aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller
diff options
context:
space:
mode:
authorJoris2016-06-25 15:10:03 +0200
committerJoris2016-06-25 22:09:04 +0200
commit70720548c9af024dbb6080638ac8e5470c2213eb (patch)
treea149bd6d8f1448de11ac4b0b41c52bc82052035a /src/server/Controller
parent4ce4de89a5400b0d8b9cddaa2922901a081fdaaa (diff)
Use the search to view either punctual or monthly payments
Diffstat (limited to 'src/server/Controller')
-rw-r--r--src/server/Controller/Payment.hs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs
index 7e8d0a3..294e4c4 100644
--- a/src/server/Controller/Payment.hs
+++ b/src/server/Controller/Payment.hs
@@ -15,7 +15,6 @@ import Database.Persist
import Control.Monad.IO.Class (liftIO)
import Data.Text (Text)
-import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Aeson.Types as Json
@@ -34,16 +33,11 @@ getPayments =
(liftIO $ runDb P.getPayments) >>= json
)
-createPayment :: Text -> Text -> Frequency -> ActionM ()
+createPayment :: Text -> Int -> Frequency -> ActionM ()
createPayment name cost frequency =
Secure.loggedAction (\user -> do
- creationResult <- liftIO . runDb $ P.createPayment (entityKey user) name cost frequency
- case creationResult of
- Left errors -> do
- status badRequest400
- jsonObject . map (\(a, b) -> (a, Json.String . T.pack . show $ b)) $ errors
- Right paymentId ->
- jsonObject [("id", Json.Number . fromIntegral . keyToInt64 $ paymentId)]
+ paymentId <- liftIO . runDb $ P.createPayment (entityKey user) name cost frequency
+ jsonObject [("id", Json.Number . fromIntegral . keyToInt64 $ paymentId)]
)
deleteOwnPayment :: Text -> ActionM ()