public ActionResult ENREGISTRERRESULTAT(ResultatVM RVM, String[] IdsExamenPrescris, String[] Resultats, String[] Commentaires) { using (IDAL dal = new Dal()) { if (dal.VerifierAccesParUtilisateurIdParPrivilegePeut(HttpContext.User.Identity.Name, "ENREGISTRER_RESULTAT")) { if (ModelState.IsValid) { List <ResultatVM2> ListeIdsExamenPrescris = new List <ResultatVM2>(); ResultatVM2 ExamenPrescris; if (IdsExamenPrescris != null) { int i = 0; foreach (var ExamId in IdsExamenPrescris) { if (ExamId != "false") { ExamenPrescris = new ResultatVM2(); ExamenPrescris.ExamenId = ExamId; if (Resultats[i] == "on") { ExamenPrescris.EstNegatif = false; } else { ExamenPrescris.EstNegatif = true; } ExamenPrescris.Description = Commentaires[i]; ListeIdsExamenPrescris.Add(ExamenPrescris); } i += 1; } } RESULTAT result = new RESULTAT(); result.Examen = dal.ObtenirExamenParId(RVM.ExamenId); result.Description = RVM.Description; if (ListeIdsExamenPrescris != null) { result.ResultatID = dal.EnregistrerResultat(result); if (result.ResultatID != null) { foreach (var Exam in ListeIdsExamenPrescris) { EXAMENDETAILS ExamDetails = dal.ObtenirExamenDetailsParId(Exam.Id); if (ExamDetails != null) { ExamDetails.Description = Exam.Description; ExamDetails.EstNegatif = Exam.EstNegatif; dal.EnregistrerExamenDetails(ExamDetails); } } } } return(RedirectToAction("CONSULTERLISTERESULTATS")); } return(RedirectToAction("ENREGISTRERRESULTAT")); } else { ViewBag.ErrorMessage = dal.getErrorMessageFailedAuthorization(); return(View("Error")); } } }
public ActionResult ENREGISTREREXAMEN(ExamenVM EVM, String[] IdsExamenAPrescrire) { using (IDAL dal = new Dal()) { if (dal.VerifierAccesParUtilisateurIdParPrivilegePeut(HttpContext.User.Identity.Name, "ENREGISTRER_EXAMEN")) { if (ModelState.IsValid) { List <String> ListeIdsExamenAPrescrire = new List <string>(); if (IdsExamenAPrescrire != null) { foreach (var ExamId in IdsExamenAPrescrire) { if (ExamId != "false") { ListeIdsExamenAPrescrire.Add(ExamId); } } } EXAMEN exam = new EXAMEN(); exam.Dossier = dal.ObtenirDossierParId(EVM.DossierId); exam.Utilisateur = dal.ObtenirUtilisateurParId(EVM.MedecinId); exam.Service = dal.ObtenirServiceParId(EVM.ServiceId); exam.ExamenType = dal.ObtenirExamenTypeParId(EVM.ExamenTypeId); exam.DateExamen = EVM.DateExamen; exam.Description = EVM.Description; if (ListeIdsExamenAPrescrire != null) { exam.ExamenID = dal.EnregistrerExamen(exam); if (exam.ExamenID != null) { foreach (var ExamId in ListeIdsExamenAPrescrire) { EXAMENMEDICAL examMedical = dal.ObtenirExamenMedicalParId(ExamId); if (examMedical != null) { EXAMENDETAILS ExamDetails = new EXAMENDETAILS(); ExamDetails.Examen = dal.ObtenirExamenParId(exam.ExamenID); ExamDetails.ExamenMedical = examMedical; dal.EnregistrerExamenDetails(ExamDetails); } } } } return(RedirectToAction("CONSULTERLISTEEXAMENS")); } return(RedirectToAction("ENREGISTREREXAMEN")); } else { ViewBag.ErrorMessage = dal.getErrorMessageFailedAuthorization(); return(View("Error")); } } }