public ActionResult EditPersonAudit(EditPersonAuditDto model) { var dbPerson = this.COVID19Entities.People.First(x => x.Personid == model.PersonID); var dbPatient = dbPerson.Patients.FirstOrDefault(); if (dbPatient == null) { dbPerson.Patients.Add(new Patient { EffectDate = DateTime.Now }); this.COVID19Entities.SaveChanges(); } var dbPatientHistory = new PatientHistory { ActionID = model.PatientActionID, EffectDate = DateTime.Now, Datetime = DateTime.Now, Observation = User.Identity.Name + " creó el nuevo registro con éxito", PatientID = dbPatient.PatientID }; this.COVID19Entities.PatientHistories.Add(dbPatientHistory); this.COVID19Entities.SaveChanges(); return(RedirectToAction("PersonalInfo", "Person", new { id = model.PersonID })); }
public ActionResult EditPersonAudit(int id) { var model = new EditPersonAuditDto { PersonID = id, PatientActions = this.COVID19Entities.PatientActions.Where(x => x.Id != 5 && x.NullDate == null).Select(x => new SelectListItem { Text = x.Action, Value = x.Id.ToString() }).ToList() }; return(View(model)); }