Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        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"));
     }
 }
Exemplo n.º 6
0
 public void Update(VMPerson person)
 {
     _bus.Send(new UpdatePersonCommand(person.Id, person.LastName, person.FirstName, person.Age));
 }
Exemplo n.º 7
0
 public void Save(VMPerson person)
 {
     _bus.Send(new CreatePersonCommand(Guid.NewGuid(), person.LastName, person.FirstName, person.Age));
 }
Exemplo n.º 8
0
 public ActionResult Add(VMPerson item)
 {
     facade.Save(item);
     return(RedirectToAction("Index"));
 }