public ActionResult Isolation(int id) { var yesNoOptions = new List <SelectListItem> { new SelectListItem { Text = "No", Value = "false" }, new SelectListItem { Text = "Si", Value = "true" } }; ViewBag.yesNoOptions = yesNoOptions; var dbPerson = this.COVID19Entities.People.First(x => x.Personid == id); var dbPatient = dbPerson.Patients.First(); // Está garantizado por el flujo de trabajo if (dbPerson.Adress == null) { dbPerson.Adress = new Adress { }; this.COVID19Entities.SaveChanges(); } var model = new NewPersonDtoStep5 { PersonID = dbPatient.PersonId.GetValueOrDefault(), InIsolation = dbPatient.Isolation, IsolationStart = dbPatient.IsolationDate, IsolationEnd = dbPatient.IsolationFinishDate, QtyPersonsInTouch = dbPatient.QtyPersonsInTouch, ContactStreet = dbPerson.Adress.Street, ContactNumber = dbPerson.Adress.Number, ContactFloor = dbPerson.Adress.Floor, ContactDept = dbPerson.Adress.Department, ContactCity = dbPerson.Adress.Location, ContactState = dbPerson.Adress.Province }; return(View(model)); }
public ActionResult Isolation(NewPersonDtoStep5 model) { if (!ModelState.IsValid) { var yesNoOptions = new List <SelectListItem> { new SelectListItem { Text = "No", Value = "false" }, new SelectListItem { Text = "Si", Value = "true" } }; ViewBag.yesNoOptions = yesNoOptions; return(View(model)); } var dbPerson = this.COVID19Entities.People.First(x => x.Personid == model.PersonID); var dbPatient = dbPerson.Patients.First(); // Está garantizado por el flujo de trabajo var dbAddress = dbPerson.Adress; dbPatient.Isolation = model.InIsolation; dbPatient.IsolationDate = model.IsolationStart; dbPatient.IsolationFinishDate = model.IsolationEnd; dbPatient.QtyPersonsInTouch = model.QtyPersonsInTouch; dbAddress.Street = model.ContactStreet; dbAddress.Number = model.ContactNumber; dbAddress.Floor = model.ContactFloor; dbAddress.Department = model.ContactDept; dbAddress.Location = model.ContactCity; dbAddress.Province = model.ContactState; this.COVID19Entities.SaveChanges(); return(RedirectToAction("Brief", "Person", new { id = model.PersonID })); }