Exemplo n.º 1
0
        public ActionResult EditProfile()
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            var PatientViewObj = new PatientProfileView((int)Session["userId"]);
            var Patient        = PatientViewObj.GetPatientProfile();
            var PatientInfo    = PatientViewObj.GetPatientInfo();
            PatientProfileEditViewModel model = new PatientProfileEditViewModel();

            AutoMapper.Mapper.Map(Patient, model);
            AutoMapper.Mapper.Map(PatientInfo, model);
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult PatientUserProfileEdit(PatientProfileEditViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            Users    user    = new Users();
            Patients patient = new Patients();

            AutoMapper.Mapper.Map(model, user);
            AutoMapper.Mapper.Map(model, patient);
            if (string.IsNullOrEmpty(model.NewPassword))
            {
                user.Password = model.Password;
            }
            else
            {
                user.Password = model.NewPassword;
            }
            PatientEdit Patient = new PatientEdit();

            try
            {
                if (Patient.UpdatePatient(user, patient))
                {
                    return(RedirectToAction($"PatientUserDetails/{model.Id}"));
                }
                else
                {
                    return(RedirectToAction($"/Patient/Profile/Edit/{model.Id}"));
                }
            }
            catch (EmailAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (PhoneAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", "Unable to update Patient information");
                return(View(model));
            }
        }
Exemplo n.º 3
0
        public ActionResult EditProfile(PatientProfileEditViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            Users    user    = new Users();
            Patients patient = new Patients();

            user.RoleId = (int)Roles.Patient;
            AutoMapper.Mapper.Map(model, user);
            AutoMapper.Mapper.Map(model, patient);
            user.Id = (int)Session["userId"];

            PatientEdit Patient = new PatientEdit();

            try
            {
                if (Patient.UpdatePatient(user, patient))
                {
                    return(RedirectToAction("Profile"));
                }
                else
                {
                    return(RedirectToAction("Profile/Edit"));
                }
            }
            catch (EmailAlreadyExistsEx ex)
            {
                throw ex;
            }
            catch (PhoneAlreadyExistsEx ex)
            {
                throw ex;
            }
            catch (Exception e)
            {
                throw e;
            }
        }