aboutsummaryrefslogtreecommitdiff
path: root/server/src/Controller/Category.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/Controller/Category.hs')
-rw-r--r--server/src/Controller/Category.hs30
1 files changed, 15 insertions, 15 deletions
diff --git a/server/src/Controller/Category.hs b/server/src/Controller/Category.hs
index 5565b43..37b8357 100644
--- a/server/src/Controller/Category.hs
+++ b/server/src/Controller/Category.hs
@@ -4,31 +4,31 @@ module Controller.Category
, delete
) where
-import Control.Monad.IO.Class (liftIO)
-import qualified Data.Text.Lazy as TL
-import Network.HTTP.Types.Status (badRequest400, ok200)
-import Web.Scotty hiding (delete)
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text.Lazy as TL
+import Network.HTTP.Types.Status (badRequest400, ok200)
+import Web.Scotty hiding (delete)
-import Common.Model (CategoryId, CreateCategory (..),
- EditCategory (..))
-import qualified Common.Msg as Msg
+import Common.Model (CategoryId, CreateCategory (..),
+ EditCategory (..))
+import qualified Common.Msg as Msg
-import Json (jsonId)
-import qualified Model.Category as Category
-import qualified Model.PaymentCategory as PaymentCategory
-import qualified Model.Query as Query
+import Json (jsonId)
+import qualified Model.Query as Query
+import qualified Persistence.Category as CategoryPersistence
+import qualified Persistence.PaymentCategory as PaymentCategoryPersistence
import qualified Secure
create :: CreateCategory -> ActionM ()
create (CreateCategory name color) =
Secure.loggedAction (\_ ->
- (liftIO . Query.run $ Category.create name color) >>= jsonId
+ (liftIO . Query.run $ CategoryPersistence.create name color) >>= jsonId
)
edit :: EditCategory -> ActionM ()
edit (EditCategory categoryId name color) =
Secure.loggedAction (\_ -> do
- updated <- liftIO . Query.run $ Category.edit categoryId name color
+ updated <- liftIO . Query.run $ CategoryPersistence.edit categoryId name color
if updated
then status ok200
else status badRequest400
@@ -38,9 +38,9 @@ delete :: CategoryId -> ActionM ()
delete categoryId =
Secure.loggedAction (\_ -> do
deleted <- liftIO . Query.run $ do
- paymentCategories <- PaymentCategory.listByCategory categoryId
+ paymentCategories <- PaymentCategoryPersistence.listByCategory categoryId
if null paymentCategories
- then Category.delete categoryId
+ then CategoryPersistence.delete categoryId
else return False
if deleted
then