Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thecodejunkie/898082 to your computer and use it in GitHub Desktop.
Save thecodejunkie/898082 to your computer and use it in GitHub Desktop.
=)
// -- BEFORE --
Post["/create"] = x =>
{
var be = new BeerEvent()
{
Name = Request.Form.Name,
Location = Request.Form.Location,
EventDate = Request.Form.EventDate
};
var res = DB.BeerEvents.Insert(be);
return RedirectToBeerEvent(res.Id);
};
Post["/update/{Id}"] = x =>
{
var be = new BeerEvent
{
Id = x.Id,
Name = Request.Form.Name,
Location = Request.Form.Location,
EventDate = Request.Form.EventDate
};
DB.BeerEvents.Update(be);
return RedirectToBeerEvent(be.Id);
};
// -- AFTER --
Post["/create"] = x =>
{
BeerEvent be = this.Bind();
var res = DB.BeerEvents.Insert(be);
return RedirectToBeerEvent(res.Id);
};
Post["/update/{Id}"] = x =>
{
BeerEvent be = this.Bind("id");
be.Id = x.Id;
DB.BeerEvents.Update(be);
return RedirectToBeerEvent(be.Id);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment