Exemple #1
0
 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());
 }