Beispiel #1
0
        public void UpdatePatient()
        {
            Users    user    = new Users();
            Patients patient = new Patients();

            user.Id                     = 22;
            user.FirstName              = "test1";
            user.LastName               = "test1";
            user.Email                  = "*****@*****.**";
            user.Address                = "bangalore";
            user.Phone                  = "1234512345";
            user.Gender                 = 1;
            user.DateOfBirth            = new DateTime(2019, 10, 21);
            user.Password               = "******";
            user.CreatedBy              = 0;
            user.RoleId                 = 4;
            patient.UserId              = 22;
            patient.ConservatorName     = "xyz";
            patient.ConservatorPhone    = "0000000000";
            patient.ConservatorRelation = "father";
            patient.Id                  = 1;
            // Act
            var result = patientEdit.UpdatePatient(user, patient);

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #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));
            }
        }
Beispiel #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;
            }
        }