Ejemplo n.º 1
0
        private int UpdateDetails(PatientDetails newPatientDetails, PatientDetailsModel sessionDetails)
        {
            int result;

            if (sessionDetails != null)
            {
                sessionDetails.DateOfBirth = newPatientDetails.DateOfBirth;
                sessionDetails.Ethnicity   = (int)newPatientDetails.Ethnicity;
                sessionDetails.Gender      = (int)newPatientDetails.Gender;
                result = PatientProcessor.UpdatePatientDetails(sessionDetails);
            }
            else
            {
                sessionDetails = new PatientDetailsModel
                {
                    DateOfBirth = newPatientDetails.DateOfBirth,
                    Ethnicity   = (int)newPatientDetails.Ethnicity,
                    Gender      = (int)newPatientDetails.Gender
                };
                result = PatientProcessor.SavePatientDetails(SessionController.GetId(HttpContext.Session), sessionDetails);
            }

            if (result == 1)
            {
                SessionController.UpdatePatientDetails(HttpContext.Session, sessionDetails);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public IActionResult ImportPatientCredentials(ImportPatientCredentials importPatientCredentials)
        {
            // if all goes well, redirect to import patients with a success message
            // otherwise, r
            if (!CsvProcessor.IsCsv(importPatientCredentials.File))
            {
                ViewData["ErrorMessage"] = "Could not upload patients, the file provided was not a CSV file.";
                return(View(viewName: "ImportPatients"));
            }

            List <string>  errorMessages = new List <string>();
            List <Patient> patients      = CsvProcessor.ReadPatients(importPatientCredentials.File, errorMessages);

            // No patients parsed then return with errors. If there are patients parsed but the user does not want to upload
            // if there are errors, then simply return with errors
            if (patients.Count == 0 || (errorMessages.Count > 0 && !importPatientCredentials.UploadWithErrors))
            {
                ViewData["ErrorMessage"] = "No patients were uploaded, check the file matches the format required.";
                return(View(viewName: "ImportPatients"));
            }

            int successfulInserts = PatientProcessor.SavePatients(Patient.Convert(patients), errorMessages);

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

            ViewData["SuccessMessage"] = $"{successfulInserts} Patients were uploaded successfully.";
            return(View(viewName: "ImportPatients"));
        }
Ejemplo n.º 3
0
        public IActionResult DeleteAccountConfirm()
        {
            var details = SessionController.GetPatientDetails(HttpContext.Session);
            int id      = details.Id;

            PatientProcessor.DeletePatient(id);
            SessionController.Logout(HttpContext.Session);
            return(View("Index"));
        }
Ejemplo n.º 4
0
        public IActionResult ChangePassword(PatientModel patientM)
        {
            int          id              = SessionController.GetId(HttpContext.Session);
            PatientModel currentPatient  = PatientProcessor.LoadPatient(id);
            String       currentPassword = currentPatient.Password;

            if (patientM.Password == currentPassword)
            {
                PatientProcessor.UpdatePatientPassword(id, patientM.NewPassword);
                return(PartialView("_StatusMessagePartial", new Tuple <bool, string>(false, $"Password Successfully Updated")));
            }
            else
            {
                return(PartialView("_StatusMessagePartial", new Tuple <bool, string>(false, $"Current Password did Not match, Password Not Updated")));
            }
        }