Exemplo n.º 1
0
        public ActionResult EditProfile()
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            var DoctorViewObj = new DoctorProfileView((int)Session["userId"]);
            var Doctor        = DoctorViewObj.GetDoctorProfile().Doctor;
            var model         = new DoctorProfileEditViewModel();

            AutoMapper.Mapper.Map(Doctor, model);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult DoctorUserProfileEdit(DoctorProfileEditViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            Users     user      = new Users();
            DoctorFee doctorFee = new DoctorFee();

            AutoMapper.Mapper.Map(model, user);
            AutoMapper.Mapper.Map(model, doctorFee);
            if (string.IsNullOrEmpty(model.NewPassword))
            {
                user.Password = model.Password;
            }
            else
            {
                user.Password = model.NewPassword;
            }
            DoctorEdit Doctor = new DoctorEdit();

            try
            {
                if (Doctor.UpdateDoctor(user, doctorFee))
                {
                    return(RedirectToAction($"DoctorUserDetails/{model.Id}"));
                }
                else
                {
                    return(RedirectToAction($"/Doctor/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 Doctor information");
                return(View(model));
            }
        }
Exemplo n.º 3
0
        public ActionResult EditProfile(DoctorProfileEditViewModel model, string returnUrl)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            Users user = new Users();

            AutoMapper.Mapper.Map(model, user);
            user.Id = (int)Session["userId"];
            if (string.IsNullOrEmpty(model.NewPassword))
            {
                user.Password = model.Password;
            }
            else
            {
                user.Password = model.NewPassword;
            }
            try
            {
                if (new DoctorEdit().UpdateDoctor(user))
                {
                    return(RedirectToAction("Profile"));
                }
                else
                {
                    return(RedirectToAction("Profile/Edit"));
                }
            }
            catch (EmailAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (PhoneAlreadyExistsEx ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }