Created
January 28, 2011 09:42
-
-
Save t0yv0/800045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Controller = | |
let handle = function | |
| ShowRecentBlogs -> | |
let blogs = Model.WithBlogs <| fun db -> db.GetRecentBlogs() | |
View.ShowRecentBlogs blogs | |
| CreateBlog -> | |
View.CreateBlog () | |
| ReadBlog id -> | |
let blog = Model.WithBlogs <| fun db -> db.ReadBlog id | |
match blog with | |
| Some blog -> | |
View.ReadBlog blog | |
| None -> | |
Content.NotFound | |
| UpdateBlog id -> | |
let blog = Model.WithBlogs <| fun db -> db.ReadBlog id | |
match blog with | |
| None -> Content.Redirect Action.CreateBlog | |
| Some blog -> View.UpdateBlog blog | |
| DeleteBlog id -> | |
let blog = Model.WithBlogs <| fun db -> | |
let blog = db.ReadBlog id | |
if blog.IsSome then | |
db.DeleteBlog id | |
|> ignore | |
blog | |
match blog with | |
| Some blog -> | |
View.BlogDeleted blog | |
| None -> | |
Content.ServerError | |
{ Handle = handle } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment