Exemplo n.º 1
0
        public ActionResult ConfirmUpdateUser (UpdateUserViewModel model)
        {
            var user = new ApplicationUser();
            user = UserManager.FindById(User.Identity.GetUserId());
            
            if (User.IsInRole("Patient"))
            {
                Patient patient = new Patient();
                patient = _patientService.GetPatient(user.PatientId);
                patient.Birthdate = model.Birthdate;
                patient.Height = model.Height;
                patient.Weight = model.Weight;
                patient.Ethnicity = (int)Enum.Parse(typeof(PatientEthnicity), model.Ethnicity);
                patient.Gender = (int)Enum.Parse(typeof(PatientGender), model.Gender);
                patient.Location = (int)Enum.Parse(typeof(Location), model.Location);
                patient.Race = (int)Enum.Parse(typeof(PatientRace), model.Race);
                _patientService.SaveChanges();
            }
            else if (User.IsInRole("Physician"))
            {
                Physician physician = new Physician();
                physician = _physicianService.GetPhysician(user.PhysicianId);
                physician.Email = model.Email;
                user.Email = model.Email;
                physician.Address = model.Address;
                physician.FirstName = model.FirstName;
                physician.LastName = model.LastName;
                physician.PhoneNumber = model.PhoneNumber;
                _physicianService.SaveChanges();
            }
            else if (User.IsInRole("Experiment Administrator"))
            {
                ExperimentAdministrator experimentAdministrator = new ExperimentAdministrator();
                experimentAdministrator = _experimentAdminService.GetExperimentAdministrator(user.ExperimentAdministratorId);
                experimentAdministrator.Email = model.Email;
                user.Email = model.Email;
                experimentAdministrator.Address = model.Address;
                experimentAdministrator.FirstName = model.FirstName;
                experimentAdministrator.LastName = model.LastName;
                experimentAdministrator.PhoneNumber = model.PhoneNumber;
                _experimentAdminService.SaveChanges();
            }
            else if (User.IsInRole("System Administrator"))
            {
                // Not yet implemented.
                user.Email = model.Email;
            }
            else
            {
                // Error path.
                ModelState.AddModelError("", "ERROR: User role not specified.");
                return View();
            }

            return (Redirect ("/Account/LoginRedirect"));
        }
Exemplo n.º 2
0
        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);
        }