Esempio n. 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());
        }
Esempio n. 2
0
        public ActionResult JsonInfo(int recordId)
        {
            FullPersonViewModel myPerson = PeopleDatabase.GetOneFullPersonByRecordId(recordId) ?? new FullPersonViewModel
            {
                RecordId   = 0,
                Name       = "Not Found",
                Age        = 0,
                ContactPic = string.Empty,
                Role       = string.Empty,
                BlogPage   = string.Empty
            };

            return(Json(myPerson, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
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();
            }
        }