From 8cd63a64abafe21378c35c2489d49f24c9ece3c9 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 4 Apr 2016 01:27:36 +0200 Subject: Add income list CRUD in user page --- src/server/Main.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/server/Main.hs') diff --git a/src/server/Main.hs b/src/server/Main.hs index c6e930a..0642288 100644 --- a/src/server/Main.hs +++ b/src/server/Main.hs @@ -11,6 +11,7 @@ import MonthlyPaymentJob (monthlyPaymentJobListener) import Data.Text (Text) import qualified Data.Text.IO as T +import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Controller.Index import Controller.SignIn @@ -62,14 +63,21 @@ api conf = do -- Users get "/api/users" getUsers + get "/api/whoAmI" whoAmI -- Incomes get "/api/incomes" getIncomes + post "/api/income" $ do + creation <- param "creation" :: ActionM Int amount <- param "amount" :: ActionM Int - setIncome amount + addIncome (posixSecondsToUTCTime $ (fromIntegral creation) / 1000) amount + + delete "/api/income/delete" $ do + incomeId <- param "id" :: ActionM Text + deleteOwnIncome incomeId -- Payments @@ -83,4 +91,4 @@ api conf = do post "/api/payment/delete" $ do paymentId <- param "id" :: ActionM Text - deletePayment paymentId + deleteOwnPayment paymentId -- cgit v1.2.3