public IActionResult OnPost() { if (ModelState.IsValid) { foreach (var virus in Viruses) { if (virus.IsSelected == true) { if (virus.Name == "Covid-19") { Diagnosis.IsPositive = true; } var diagnosisVirus = new DiagnosisVirus(); diagnosisVirus.Virus = virusService.GetVirusById(virus.Id); Diagnosis.DiagnosisViruses.Add(diagnosisVirus); } } if (Diagnosis.Id == 0) { Diagnosis.PatientId = Patient.Id; Diagnosis = diagnosisService.CreateDiagnosis(Diagnosis); } else { Patient = patientService.GetPatientById(Patient.Id); var diagnose = diagnosisService.GetDiagnosisById(Diagnosis.Id); Patient.Diagnosis.Remove(diagnose); Patient.Diagnosis.Add(Diagnosis); } diagnosisService.Commit(); return(RedirectToPage("./DiagnosisList", new { id = Diagnosis.PatientId })); } return(Page()); }
public IActionResult OnPostDeleteDiagnosis(int id) { var temp = diagnosesService.DeleteDiagnosis(id); if (temp == null) { return(RedirectToPage("NotFound")); } diagnosesService.Commit(); return(RedirectToPage("/Diagnosis/DiagnosisList", new { id = temp.PatientId })); }