public ActionResult Delete(Person model) { using (var tran = RepositoryFactory.StartTransaction()) { var itemToDelete = RepositoryFactory.Command<IPersonCommand>().FindByPk("people/" + model.Id); RepositoryFactory.Command<IPersonCommand>().Delete(itemToDelete); tran.Commit(); SessionFactory.WaitForStaleIndexes(); return RedirectToActionWithAjax("Index"); } }
public ActionResult Edit(Person model) { if (ModelState.IsValid) { using (var tran = RepositoryFactory.StartTransaction()) { var realItem = RepositoryFactory.Command<IPersonCommand>().FindByPk("people/" + model.Id); realItem.FullName = model.FullName; realItem.Occupation = model.Occupation; realItem.Img = model.Img; RepositoryFactory.Command<IPersonCommand>().Update(realItem); tran.Commit(); SessionFactory.WaitForStaleIndexes(); return RedirectToActionWithAjax("Index"); } } return ViewWithAjax(model); }
public ActionResult Store(Person person) { using (var tran = RepositoryFactory.StartTransaction()) { if (string.IsNullOrEmpty(person.Img)) { person.Img = "/Content/images/anonym.png"; } if (string.IsNullOrEmpty(person.Id)) { RepositoryFactory.Command<IPersonCommand>().Create(person); } else { RepositoryFactory.Command<IPersonCommand>().Update(person); } tran.Commit(); } return Json(new { result = true }); }