public ActionResult Index(int id = 0) { var vm = new PersonViewModel(); if (id > 0) { Run("PersonController.Index(id)", () => { var person = Person.Find(i => i.Id == id, includes: new string[] { "NaturalPerson", "LegalPerson", "Doctor" }); if (person != null) vm = new PersonViewModel(person); return vm; }, id); } return View(vm); }
public ActionResult Post(PersonViewModel personVm) { if (personVm != null) { Run("PersonController.Post(id)", () => { personVm.SaveProfileImage(); Person.AddOrUpdate(i => i.Id, personVm.Person); NotificationViewModel.AddToCookie("Processo finalizado com sucesso!", "Sucesso!", 10000, NotificationIconType.Success); }, personVm.Person.Id); return RedirectToRoute("Person", new { id = personVm.Person.Id }); } else { NotificationViewModel.AddToCookie("Ocorreu um problema ao salvar o registro!", iconType: NotificationIconType.Error); } return RedirectToRoute("Error", new { RedirectUrl = string.Format("~/cadastro/pessoa") }); }