예제 #1
0
        public IActionResult Index()
        {
            //Clinician
            ClinicianManagerModel clinicianManagerModel = new ClinicianManagerModel
            {
                Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians()),
            };

            return(View(clinicianManagerModel));
        }
예제 #2
0
        public IActionResult Index(ImportClinicianCredentials clinicianCredentials)
        {
            ClinicianManagerModel clinicianManagerModel = new ClinicianManagerModel();

            if (clinicianCredentials.File == null)
            {
                ViewData["ErrorMessage"]         = "Could not upload clinicians, no file was provided.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            if (!CsvProcessor.IsCsv(clinicianCredentials.File))
            {
                ViewData["ErrorMessage"]         = "Could not upload clinicians, the file provided was not a CSV file.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            var errorMessages = CsvProcessor.GetClinicianCredentials(clinicianCredentials.File, out List <Clinician> clinicians);

            if (clinicians.Count == 0 || (errorMessages.Count > 0 && !clinicianCredentials.UploadWithErrors))
            {
                ViewData["ErrorMessage"]         = "No clinicians were uploaded, check the file matches the format required.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            int successfulInserts = ClinicianProcessor.SaveClinicians(Clinician.Convert(clinicians), errorMessages);

            if (errorMessages.Count != 0)
            {
                ViewData["ErrorMessages"] = errorMessages;
            }

            ViewData["SuccessMessage"]       = $"{successfulInserts} Clinicians were uploaded successfully.";
            clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
            return(View(clinicianManagerModel));
        }