-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathForms.fs
33 lines (27 loc) · 899 Bytes
/
Forms.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module FreyaMusicStore.Forms
open Arachne.Http
open Arachne.Uri.Template
open Freya.Core
open Freya.Core.Operators
open Freya.Machine
open Freya.Machine.Extensions.Http
open Freya.Machine.Router
open Freya.Router
type IdAndName =
{ Id : int
Name : string }
type CreateAlbum =
{ Genres : IdAndName []
Artists : IdAndName [] }
let createAlbumForm =
freya {
let ctx = Db.getContext()
let genres = Db.getGenres ctx |> Array.map (fun g -> { Id = g.GenreId; Name = g.Name })
let artists = Db.getArtists ctx |> Array.map (fun a -> { Id = a.ArtistId; Name = a.Name })
return! writeHtml ("albumCreate", { Genres = genres; Artists = artists } )
}
let createAlbum =
freyaMachine {
including common
methodsSupported ( freya { return [ GET ] } )
handleOk (fun _ -> createAlbumForm) } |> FreyaMachine.toPipeline