aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller
diff options
context:
space:
mode:
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 ()