Exemplo n.º 1
0
 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");
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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 });
        }