Exemplo n.º 1
0
        public ActionResult PartialPassword(string id)
        {
            EditPasswordViewModel model = new EditPasswordViewModel();
            model.UserId = int.Parse(id);
            model.UserName = System.Web.HttpContext.Current.Request.Cookies["User"].Value;

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult EditPassword(EditPasswordViewModel model)
        {
            try
            {
                UserDto dto = new UserDto();
                Message msg = new Message();
                DataTable dt = CMSService.SelectOne("User", "CMSUser", "UserPassword='******' and UserId=" + model.UserId);
                if (dt.Rows.Count == 0)
                {

                    msg.MessageStatus = "Error";
                    msg.MessageInfo = "原密码错误";
                    ViewBag.Status = msg.MessageStatus;
                    ViewBag.msg = msg.MessageInfo;
                    return View("UserInfo");
                }
                else
                {

                    msg = CMSService.UpdateFieldOneByOne("User", "CMSUser", "UserPassword='******' and UserId=" + model.UserId, "UserPassword",  CommonTools.ToMd5(model.UserPassword));

                    msg.MessageStatus = "Success";
                    msg.MessageInfo = "密码修改成功了";
                    ViewBag.Status = msg.MessageStatus;
                    // TODO: Add delete logic here

                    return RedirectTo("/Login/Login", msg.MessageInfo);
                }

            }
            catch
            {
                Message msg = new Message();
                msg.MessageStatus = "Error";
                msg.MessageInfo = "操作出错了";
                ViewBag.Status = msg.MessageStatus;
                ViewBag.msg = msg.MessageInfo;
                return View("UserInfo");
            }
        }