Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Created March 5, 2011 18:57
Show Gist options
  • Save grumpydev/856613 to your computer and use it in GitHub Desktop.
Save grumpydev/856613 to your computer and use it in GitHub Desktop.
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