コード例 #1
0
ファイル: UserController.cs プロジェクト: applenele/NewRen
        public ActionResult PwdEdit(vPwdEdit model)
        {
            User user = db.Users.Find(model.ID);
            if (user != null)
            {
                try
                {
                    if (ModelState.IsValid)
                    {

                        if (!string.IsNullOrEmpty(model.Password))
                        {
                            if (!user.Password.Equals(Helpers.Encryt.GetMD5(model.Password)))
                            {
                                return Redirect("/Shared/Info?msg=" + "您输入原始密码错误!");
                            }
                            else
                            {
                                user.Password = Helpers.Encryt.GetMD5(model.PasswordNew);
                                db.SaveChanges();
                                return RedirectToAction("Show/" + model.ID);
                            }
                        }
                        else
                        {
                            return RedirectToAction("Show/" + model.ID);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "修改的信息输入错误!");
                    }
                    ViewBag.user = new vPwdEdit(user);
                    return View(model);
                }
                catch (Exception ex)
                {
                    log.Error(new LogContent("修改个人密码信息出错", HttpHelper.GetIPAddress()), ex);
                    return Redirect("/User/DescriptionShow/" + model.ID);
                }
            }
            else
            {
                return Redirect("/Shared/info?msg=该用户不存在,请不要不合理操作");
            }
        }
コード例 #2
0
 public ActionResult UserPwdEdit(vPwdEdit model, int id)
 {
     User user = db.Users.Find(model.ID);
     if (user == null)
     {
         return Redirect("/Shared/Info?msg=该牛人不存在,请不要不合理操作");
     }
     else
     {
         if (ModelState.IsValid)
         {
             if (!string.IsNullOrEmpty(model.Password))
             {
                 if (!user.Password.Equals(Helpers.Encryt.GetMD5(model.Password)))
                 {
                     return Redirect("/Shared/Info?msg=" + "您输入原始密码错误!");
                 }
                 else
                 {
                     try
                     {
                         user.Password = Helpers.Encryt.GetMD5(model.PasswordNew);
                         db.SaveChanges();
                         return RedirectToAction("UserShow/" + user.ID);
                     }
                     catch (Exception ex)
                     {
                         log.Error(new LogContent("牛人密码修改出错", HttpHelper.GetIPAddress()), ex);
                         ModelState.AddModelError("", "保存修改信息出现错误,请重试!");
                     }
                 }
             }
             else
             {
                 return RedirectToAction("UserShow/" + user.ID);
             }
         }
         else
         {
             ModelState.AddModelError("", "修改的信息输入错误!");
         }
         ViewBag.user = new vPwdEdit(user);
         return View();
     }
 }
コード例 #3
0
 public ActionResult PwdEdit(vPwdEdit model, int id)
 {
     UserGroup user = db.UserGroups.Find(model.ID);
     if (ModelState.IsValid)
     {
         if (!string.IsNullOrEmpty(model.Password))
         {
             string Password = Helpers.Encryt.GetMD5(model.Password);
             if (!user.LoginPassword.Equals(Password))
             {
                 ModelState.AddModelError("", "您输入原始密码错误!");
             }
             else
             {
                 try
                 {
                     user.LoginPassword = Helpers.Encryt.GetMD5(model.PasswordNew);
                     db.SaveChanges();
                     return RedirectToAction("Show/" + user.ID);
                 }
                 catch (Exception ex)
                 {
                     log.Error(new LogContent("修改牛棚密码信息出错", HttpHelper.GetIPAddress()), ex);
                     ModelState.AddModelError("", "密码信息保存出现问题,请重试!");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "原始密码不能为空!");
         }
     }
     else
     {
         ModelState.AddModelError("", "信息填写错误!");
     }
     UserGroup group = db.UserGroups.Find(model.ID);
     ViewBag.Group = new vPwdEdit(group);
     return View();
 }
コード例 #4
0
 public ActionResult PwdEdit(vPwdEdit model, int id)
 {
     Business business = db.Businesses.Find(model.ID);
     if (!string.IsNullOrEmpty(model.Password))
     {
         string Password = Helpers.Encryt.GetMD5(model.Password);
         if (!business.LoginPassword.Equals(Password))
         {
             ModelState.AddModelError("", "您输入原始密码错误!");
         }
         else
         {
             try
             {
                 business.LoginPassword = Helpers.Encryt.GetMD5(model.PasswordNew);
                 db.SaveChanges();
                 return RedirectToAction("Show/" + model.ID);
             }
             catch (Exception ex)
             {
                 log.Error(new LogContent("修改商户密码页面出错", HttpHelper.GetIPAddress()), ex);
                 ModelState.AddModelError("", "您输入密码信息有误!");
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "您输入密码不能为空!");
     }
     ViewBag.Business = new vPwdEdit(db.Businesses.Find(business.ID));
     return View();
 }