public ActionResult Create(Device model) { if (ModelState.IsValid) { using (var tran = RepositoryFactory.StartTransaction()) { RepositoryFactory.Command<IDeviceCommands>().Create(model); tran.Commit(); SessionFactory.WaitForStaleIndexes(); return RedirectToActionWithAjax("Index"); } } return ViewWithAjax(model); }
public ActionResult Delete(Device model) { if (ModelState.IsValid) { using (var tran = RepositoryFactory.StartTransaction()) { var itemToDelete = RepositoryFactory.Command<IDeviceCommands>().FindByPk("devices/" + model.Id); RepositoryFactory.Command<IDeviceCommands>().Delete(itemToDelete); tran.Commit(); SessionFactory.WaitForStaleIndexes(); return RedirectToActionWithAjax("Index"); } } return ViewWithAjax(model); }