// // GET: /Manage/Index public async Task<ActionResult> Index(ManageMessageId? message) { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); string accountRole = ""; //user = UserManager.FindById(userId); UserRole userRole = UserRole.Patient; if (User.IsInRole(UserRole.Patient.ToString())) { userRole = UserRole.Patient; accountRole = UserRole.Patient.ToString(); } else if (User.IsInRole(UserRole.Physician.ToString())) { userRole = UserRole.Physician; accountRole = UserRole.Physician.ToString(); } else if (User.IsInRole(UserRole.Experiment_Administrator.ToString().Replace("_", " "))) { userRole = UserRole.Experiment_Administrator; accountRole = UserRole.Experiment_Administrator.ToString().Replace("_", " "); } else { userRole = UserRole.System_Administrator; accountRole = UserRole.System_Administrator.ToString().Replace("_", " "); } ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; IndexViewModel model = new IndexViewModel { HasPassword = (user.PasswordHash != null) ? true : false, PhoneNumber = user.PhoneNumber, TwoFactor = user.TwoFactorEnabled, //Logins = user.Logins, //BrowserRemembered = user.brows AccountRole = accountRole }; switch (userRole) { case UserRole.Patient: // Patient Patient patient = new Patient(); patient = _patientService.GetPatient(user.PatientId); model.Username = user.UserName; model.Weight = patient.Weight; model.Height = patient.Height; model.Race = patient.Race.ToString(); model.Ethnicity = patient.Ethnicity.ToString(); model.Location = patient.Location.ToString(); model.Birthdate = patient.Birthdate; model.Gender = patient.Gender.ToString(); break; case UserRole.Physician: // Physician Physician physician = new Physician(); physician = _physicianService.GetPhysician(user.PhysicianId); model.Email = physician.Email; model.Username = user.UserName; model.Address = physician.Address; model.PhoneNumber = physician.PhoneNumber; model.FirstName = physician.FirstName; model.LastName = physician.LastName; break; case UserRole.Experiment_Administrator: // Experiment Administrator ExperimentAdministrator experimentAdministrator = new ExperimentAdministrator(); experimentAdministrator = _experimentAdminService.GetExperimentAdministrator(user.ExperimentAdministratorId); model.Email = experimentAdministrator.Email; model.Username = user.UserName; model.Address = experimentAdministrator.Address; model.PhoneNumber = experimentAdministrator.PhoneNumber; model.FirstName = experimentAdministrator.FirstName; model.LastName = experimentAdministrator.LastName; break; case UserRole.System_Administrator: // System Admin model.Username = user.UserName; model.Email = user.Email; break; default: // Display error break; } return View(model); }
public ActionResult UpdateUser(IndexViewModel inmodel) { UpdateUserViewModel model = new UpdateUserViewModel(); model.AccountRole = inmodel.AccountRole; model.Address = inmodel.Address; model.Birthdate = inmodel.Birthdate; model.Email = inmodel.Email; model.Ethnicity = inmodel.Ethnicity; model.FirstName = inmodel.FirstName; model.Gender = inmodel.Gender; model.Height = inmodel.Height; model.LastName = inmodel.LastName; model.Location = inmodel.Location; model.PhoneNumber = inmodel.PhoneNumber; model.Race = inmodel.Race; model.Username = inmodel.Username; model.Weight = inmodel.Weight; return View(model); }