Commit b880a31d authored by Nicolas Lenz's avatar Nicolas Lenz

Delete methods

parent 8a4eb398
Pipeline #434 passed with stage
in 5 minutes and 23 seconds
/container/#Int ContainerR GET PUT
/container/#Int ContainerR GET PUT DELETE
/container ContainersR GET
/containers.csv ContainersCsvR GET
/location/#Text LocationR GET PUT
/location/#Text LocationR GET PUT DELETE
/location LocationsR GET
/add AddR POST
......
......@@ -5,6 +5,7 @@ module Handler.Container where
import Import
-- | An allocation without the container number.
data FreeAllocation = FreeAllocation {
location :: Text,
amount :: Maybe Int
......@@ -37,6 +38,11 @@ putContainerR number = do
runDB $ putMany $ map (unfreeAllocation number) newAllocations
returnJson ("Success" :: Text)
deleteContainerR :: Int -> Handler Value
deleteContainerR number = do
runDB $ deleteWhere [AllocationContainer ==. number]
returnJson ("Success" :: Text)
getContainersR :: Handler Value
getContainersR = do
allocations <- runDB $ selectList [] []
......
......@@ -38,6 +38,11 @@ putLocationR code = do
runDB $ putMany $ map (unfreeAllocation code) newAllocations
returnJson ("Success" :: Text)
deleteLocationR :: Text -> Handler Value
deleteLocationR code = do
runDB $ deleteWhere [AllocationLocation ==. code]
returnJson ("Success" :: Text)
getLocationsR :: Handler Value
getLocationsR = do
allocations <- runDB $ selectList [] []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment