Floorplan Updated

This commit is contained in:
2021-11-09 17:16:29 +10:00
parent 49fcdabf0f
commit 61481ad87c
37 changed files with 1862 additions and 1762 deletions

View File

@@ -6,10 +6,11 @@ open System.Text.RegularExpressions
open DredgeFramework
open Dapper
open Dapper.FSharp
open Floorplan
[<CLIMutable>]
type floorplan_decoration = {
decoration_id: int
id: int
decoration_room: int
decoration_pos_x: int
decoration_pos_y: int
@@ -19,12 +20,14 @@ type floorplan_decoration = {
decoration_image: string
}
type decoration_creator = {
decoration_room: int
decoration_image: string
basis: int
}
let decorationList venue =
select {
table "floorplan_decorations"
innerJoin "floorplan_rooms" "id" "decoration_room"
}
|> db.SelectJoin<floorplan_decoration, floorplan_room>
|> Array.filter (fun (_, room) -> room.venue_id = venue )
|> Array.map fst
let decorationsInRoom (roomId: int) =
select {
@@ -43,8 +46,6 @@ let getImageName (image: string, path: string) =
imageName, path
let isImageFile (fileName: string) = Regex.IsMatch(fileName |> ToLowerCase, @"^.+\.(jpg|jpeg|png|gif)$")
let getImageHTML (imageName: string, imageUrl: string) =
@@ -77,20 +78,21 @@ let CreateDecoration (decoration: floorplan_decoration) =
insert {
table "floorplan_decorations"
value decoration
} |> db.Insert
}
|> db.InsertOutput
|> first
let UpdateDecoration (decoration: floorplan_decoration) =
let imageFile = GetFileName decoration.decoration_image
let updatedDecoration = {decoration with decoration_image = imageFile}
update {
table "floorplan_decorations"
set updatedDecoration
where (eq "decoration_id" decoration.decoration_id )
set decoration
where (eq "id" decoration.id )
} |> db.Update
let DeleteDecorationById (id: int) =
let DeleteDecoration (decoration: floorplan_decoration) =
delete {
table "floorplan_decorations"
where (eq "decoration_id" id)
} |> db.Delete
where (eq "id" decoration.id)
} |> db.Delete |> ignore
decoration