public ActionResult ChangePassword(Models.ChangePasswordViewModel model)
        {
            if (model.OldPassword.Trim() == "")
            {
                return(View(model));
            }

            var myAccount         = DB_GEN_Repo.GetUser(model.UserID);   // DB_GEN.GenProxyAccount.Find(model.UserID.Trim());
            var myProxyAccount    = hluser_Repo.GetUser(model.UserID);   // hluser.passwd.Find(model.UserID.Trim());
            var myMedProxyAccount = MedProxy_Repo.GetUser(model.UserID); // MedProxy.passwd.Find(model.UserID.Trim());

            if ((myAccount == null) || (myProxyAccount == null) || (myMedProxyAccount == null))
            {
                return(View("AccountNotFound"));
            }

            string OldPasswordMD5 = DB_GEN_Repo.GetMD5(model.OldPassword); // DB_GEN.GetMD5(model.OldPassword).First().ToUpper();

            if (myAccount.chXData != OldPasswordMD5)
            {
                return(View("PasswordIncorrect"));
            }

            if (model.NewPassword != model.NewPasswordConfirm)
            {
                return(View("PasswordInconfirm"));
            }

            string NewPasswordMD5 = DB_GEN_Repo.GetMD5(model.NewPassword); //DB_GEN.GetMD5(model.NewPassword).First().ToUpper();

            myAccount.chXData        = NewPasswordMD5;
            myAccount.dtLastModified = DateTime.Now;
            myAccount.chXDataHosp    = "Web";
            DB_GEN_Repo.UnitOfWork.Commit(); //DB_GEN.SaveChanges();

            myProxyAccount.password = NewPasswordMD5.ToLower();
            myProxyAccount.comment  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "; Update by web";
            hluser_Repo.UnitOfWork.Commit(); //hluser.SaveChanges();

            myMedProxyAccount.password = NewPasswordMD5.ToLower();
            myMedProxyAccount.comment  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "; Update by web";
            MedProxy_Repo.UnitOfWork.Commit(); // MedProxy.SaveChanges();

            return(View("PasswordChanged"));
        }
Beispiel #2
0
        public ActionResult NewAccount(Models.NewAccountViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            Models.DB_GEN.GenProxyAccount newAccount = new Models.DB_GEN.GenProxyAccount();
            newAccount.chUserID       = model.UserID;
            newAccount.chUserName     = model.UserName;
            newAccount.chDeptName     = model.DeptName;
            newAccount.chEMail        = model.NoteID;
            newAccount.dtEndDate      = model.dtEndDate;
            newAccount.dtLastModified = DateTime.Now;
            newAccount.chXData        = DB_GEN_Repo.GetMD5(model.UserID);
            newAccount.chXDataHosp    = "Web";

            DB_GEN_Repo.Add(newAccount);

            DB_GEN_Repo.UnitOfWork.Commit();

            return(View("AccountAdded", model));
        }