From 70720548c9af024dbb6080638ac8e5470c2213eb Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 25 Jun 2016 15:10:03 +0200 Subject: Use the search to view either punctual or monthly payments --- src/server/Controller/Payment.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/server/Controller/Payment.hs') 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 () -- cgit v1.2.3