Example #1
0
        public ActionResult Edit(FullPersonViewModel fullPerson)
        {
            if (ModelState.IsValid)
              {
            PeopleDatabase.UpdateFullPerson(fullPerson);
            return RedirectToAction("Index", "Home");
              }

              //TODO: figure out how to send full model to web component, not just ID for it to load from.
              ViewBag.recordId = fullPerson.RecordId;
              return View();
        }
Example #2
0
        public static void UpdateFullPerson(FullPersonViewModel personDetails)
        {
            Mapper.CreateMap<FullPersonViewModel, Person>()
            .ForMember(dest => dest.RecordId, opt => opt.Ignore());

              using(var dataStore = new Store())
              {
            var originalRecord = dataStore.People.Find(personDetails.RecordId);

            if(originalRecord != null)
            {
              originalRecord = Mapper.Map<FullPersonViewModel, Person>(personDetails, originalRecord);
            }

            dataStore.SaveChanges();
              }
        }