예제 #1
0
        public ActionResult Update(PersonView personView)
        {
            
            if (!this.ModelState.IsValid)
            {
                return View("Edit");
            }
            Mapper.CreateMap<PersonView, Name>().
                ForMember(dest => dest.First, opt => opt.MapFrom(src => src.NameFirst)).
                ForMember(dest => dest.Last, opt => opt.MapFrom(src => src.NameLast));

            Mapper.CreateMap<PersonView, Person>();
            var person = Mapper.Map<PersonView, Person>(personView);
            person.Name = Mapper.Map<PersonView, Name>(personView);            
            db.Session.SaveOrUpdate(person);
            return RedirectToAction("Index");
        }
예제 #2
0
        public ActionResult Edit(int? id)
        {
            PersonView personToEdit=new PersonView();;
            if (id==null)
            {

                personToEdit = new PersonView();
                personToEdit.Id = -1;
            }
            else
            {
                //using (var tx = _session.BeginTransaction())
                //{
                //    personToEdit = _session.Get<Person>(id);
                //    tx.Commit();
                //}

            }
            return View(personToEdit);
        }