Created
March 5, 2011 18:57
-
-
Save grumpydev/856613 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
namespace Nancy.BindingDemo | |
{ | |
using System.Linq; | |
using Nancy.BindingDemo.Database; | |
using Nancy.BindingDemo.Models; | |
using Nancy.ModelBinding; | |
public class MainModule : NancyModule | |
{ | |
public MainModule() | |
{ | |
Get["/"] = x => | |
{ | |
var model = DB.Events.OrderBy(e => e.Time).ToArray(); | |
return View["Index", model]; | |
}; | |
Post["/events"] = x => | |
{ | |
Event model = this.BindModel(); | |
var model2 = this.BindModel<Event>(); | |
DB.Events.Add(model); | |
DB.Events.Add(model2); | |
return Response.AsRedirect("/"); | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment