コード例 #1
0
ファイル: PhysicianController.cs プロジェクト: trwq63/med656
        public ActionResult DisablePatientConfirm(string username)
        {
            DisablePatientViewModel model = new DisablePatientViewModel();
            ApplicationUser user = UserManager.FindByName(username); // The patient account
            Patient patient = _patientService.GetPatient(user.PatientId);
            ApplicationUser physicianUser = UserManager.FindByName(User.Identity.Name);
            Physician physician = _physicianService.GetPhysician(physicianUser.PhysicianId);

            // Check to verify that the patient is a patient for the current physician.
            if (!PatientBelongsToPhysician(patient, physician))
            {
                ModelState.AddModelError("", "Error: You cannot disable somebody that is not your patient.");
                return View(model);
            }

            UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = false
            };

            user.Status = (int)Account_Status.Inactive;
            var result = UserManager.Update(user);

            return Redirect("/Account/LoginRedirect");
        }
コード例 #2
0
ファイル: PhysicianController.cs プロジェクト: trwq63/med656
        /// <summary>
        /// This function confirms that a physician wishes to disables a patient in the database
        /// </summary>
        /// <param name="username">Username of the patient</param>
        /// <returns></returns>
        public ActionResult DisablePatient(string username)
        {
            DisablePatientViewModel model = new DisablePatientViewModel();

            // Check if username is null, if so - return early.
            if (username == null)
            {
                model.Username = "******"; // So model does not crash
                ModelState.AddModelError("", "Error: username is null");
                return View(model);
            }

            ApplicationUser patientUser = UserManager.FindByName(username);
            Patient patient = _patientService.GetPatient(patientUser.PatientId);
            ApplicationUser physicianUser = UserManager.FindByName(User.Identity.Name);
            Physician physician = _physicianService.GetPhysician(physicianUser.PhysicianId);

            // Check to verify that the patient is a patient for the current physician.
            if (!PatientBelongsToPhysician(patient, physician))
            {
                ModelState.AddModelError("", "Error: You cannot disable somebody that is not your patient.");
                return View(model);
            }

            model.Username = username;
            return View(model);
        }