Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created July 21, 2014 17:56
Show Gist options
  • Select an option

  • Save mgroves/0252d966ecf23db56060 to your computer and use it in GitHub Desktop.

Select an option

Save mgroves/0252d966ecf23db56060 to your computer and use it in GitHub Desktop.
public class AjaxController : Controller
{
readonly IDatabase _db;
public AjaxController(IDatabase db)
{
_db = db;
}
// ... snip ...
[HttpGet]
public PartialViewResult GetLedgerEditRow(int id)
{
var ledger = _db.Query(new GetLedgerByIdQuery(id));
return PartialView(ledger);
}
}
public class AjaxController : Controller
{
readonly IDatabase _db;
public AjaxController(IDatabase db)
{
_db = db;
}
// ... snip ...
[HttpPost]
public ActionResult CreateLedger(LedgerEntity ledger)
{
if (ModelState.IsValid)
{
_db.Execute(new CreateLedgerCommand(ledger));
return new HttpStatusCodeResult(HttpStatusCode.Created, "it worked");
}
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Errors");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment