public ActionResult Edit(Guid id) { var item = facade.GetById(id); var model = new VMPerson() { Id = item.Id, LastName = item.LastName, FirstName = item.FirstName, Age = item.Age, }; return(View(model)); }
public VMPerson GetById(Guid id) { var person = _readmodel.GetById <Person>(id); VMPerson personviewmodel = new VMPerson(); if (person != null) { personviewmodel.Id = person.Id; personviewmodel.LastName = person.LastName; personviewmodel.FirstName = person.FirstName; personviewmodel.Age = person.Age; } return(personviewmodel); }
public ActionResult Edit(VMPerson item) { try { facade.Update(item); } catch (ConcurrencyException err) { ViewBag.error = err.Message; ModelState.AddModelError("", err.Message); return(View()); } return(RedirectToAction("Index")); }
public IEnumerable <VMPerson> GetAll() { var persons = _readmodel.GetItems <Person>(); List <VMPerson> vmList = new List <VMPerson>(); foreach (Person person in persons) { var vm = new VMPerson(); vm.Id = person.Id; vm.LastName = person.LastName;; vm.FirstName = person.FirstName; vm.Age = person.Age; vmList.Add(vm); } return(vmList); }
public ActionResult Edit(VMPerson vm) { using (ISession session = Hook.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.SaveOrUpdate(vm); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); return(View()); } } return(RedirectToAction("Index")); } }
public void Update(VMPerson person) { _bus.Send(new UpdatePersonCommand(person.Id, person.LastName, person.FirstName, person.Age)); }
public void Save(VMPerson person) { _bus.Send(new CreatePersonCommand(Guid.NewGuid(), person.LastName, person.FirstName, person.Age)); }
public ActionResult Add(VMPerson item) { facade.Save(item); return(RedirectToAction("Index")); }