Пример #1
0
        public async Task <ActionResult> ResetPassword(int id)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            IPasswordPolicy Password        = new RandomPassword();
            string          orginalPassword = Password.GeneratePassword();

            orginalPassword = "******";
            string md5Password = HashEncrypt.MD5(orginalPassword);

            VM.UserInfoItem model = new VM.UserInfoItem();
            model = empBL.GetItemById(id);
            //IdentityModel user = await UserManager.FindByNameAsync(model.LogonName);
            //string password = UserManager.PasswordHasher.HashPassword(md5Password);
            //UserStore store = new UserStore(UserHelper.GetCurrentUser().LogonName);
            //var set = store.SetPasswordHashAsync(user, password);
            //var result = store.UpdateAsync(user);

            model.Password = md5Password;
            empBL.UpdatePasswordDb(model);
            if (model != null)
            {
                // empBL.SendEmail(model, orginalPassword, "User_ResetPassword");
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        //[AllowAnonymous]
        public async Task <ActionResult> UpdatePassword(VM.UserInfoUpdatePassword modelNew)
        {
            if (modelNew.UserId != Convert.ToInt32(UserHelper.GetCurrentUser().Id))
            {
                return(Redirect(Url.Action("Index", "NoPermissions", new { area = "" })));
            }
            BL.UserInfo     empBL = new BL.UserInfo();
            VM.UserInfoItem model = new VM.UserInfoItem();
            // model.UserId = CommonMethod.getIntValue(UserHelper.GetCurrentUser().Id);
            model = empBL.GetItemById(model.UserId);
            IdentityModel user = await UserManager.FindByNameAsync(model.LogonName);

            //modelNew.Password = HashEncrypt.MD5(modelNew.Password);
            var results = await UserManager.CheckPasswordAsync(user, modelNew.Password);

            if (results)
            {
                //modelNew.NewPassword = HashEncrypt.MD5(modelNew.NewPassword);
                string    password = UserManager.PasswordHasher.HashPassword(modelNew.NewPassword);
                UserStore store    = new UserStore(UserHelper.GetCurrentUser().LogonName);
                var       set      = store.SetPasswordHashAsync(user, password);
                var       result   = store.UpdateAsync(user);
                if (user != null)
                {
                    return(Content("Success"));
                }
            }
            else
            {
                return(Content("Error"));
            }
            return(Content("False"));
        }
Пример #3
0
        public ActionResult UserEdit()
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            int         id    = Convert.ToInt32(UserHelper.GetCurrentUser().Id);
            var         model = empBL.GetItemById(id);

            return(View(model));
        }
Пример #4
0
        public ActionResult GetDetail(int id)
        {
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            var model = empBL.GetItemById(id);

            return(PartialView("_Detail", model));
        }
Пример #5
0
        public ActionResult UpdatePassword()
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            int         id    = Convert.ToInt32(UserHelper.GetCurrentUser().Id);
            var         model = empBL.GetItemById(id);

            VM.UserInfoUpdatePassword updtaePassword = new VM.UserInfoUpdatePassword();
            updtaePassword.UserId = model.UserId;
            return(View(updtaePassword));
        }
Пример #6
0
        //
        // GET: /SystemMaint/UserInfo/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.ShowSubmit = true;
            BL.UserInfo empBL = new BL.UserInfo();
            if (empBL.GetItemByIdForDelete(id) != null)
            {
                return(Redirect(Url.Action("HttpError", "Error", new { area = "" })));
            }
            var model = empBL.GetItemById(id);

            model.RoleSelectList = GetRoleSelectList(model.RoleSelectList);
            //model.CompanySelectList = GetCompanySelectList(model.CompanySelectList);
            return(View(model));
        }
Пример #7
0
 public ActionResult GetGasStationMaps(int id, string value)
 {
     BL.UserInfo     empBL = new BL.UserInfo();
     VM.UserInfoItem model = new VM.UserInfoItem();
     if (id > 0)
     {
         model = empBL.GetItemById(id);
     }
     if (value != null)
     {
         //  model = empBL.GetItemByCompany(model, value);
     }
     model.UserCompanyValue = value;
     return(PartialView("_GasStationMap", model));
 }
Пример #8
0
        public ActionResult UserEdit(VM.UserInfoItem model)
        {
            if (!new EmailExAttribute().IsValid(model.EmailAddress))
            {
                return(Content("False"));
            }
            BL.UserInfo empBL    = new BL.UserInfo();
            var         userEdit = empBL.GetItemById(model.UserId);

            userEdit.UserName     = model.UserName;
            userEdit.EmailAddress = model.EmailAddress;
            userEdit.UpdatedBy    = "sysAdmin";//UserHelper.GetCurrentUser().LogonName;
            empBL.UserUpdate(userEdit);

            return(Content("Success"));
        }