Esempio n. 1
0
 public ActionResult ChangeInfo(User user)
 {
     userRsy = new UserRepository();
     if(userRsy.Authentication(UserName,Ninesky.Common.Text.Sha256(user.Password))==0)
     {
         var _user = userRsy.Find(UserName);
         _user.Gender = user.Gender;
         _user.Email = user.Email;
         _user.QQ = user.QQ;
         _user.Tel = user.Tel;
         _user.Address = user.Address;
         _user.PostCode = user.PostCode;
         if (userRsy.Update(_user))
         {
             Notice _n = new Notice { Title = "修改资料成功", Details = "您已经成功修改资料!", DwellTime = 5, NavigationName = "用户首页", NavigationUrl = Url.Action("Default", "User") };
             return RedirectToAction("UserNotice", "Prompt", _n);
         }
         else
         {
             Error _e = new Error { Title = "修改资料失败", Details = "在修改用户资料时时,更新的资料未能保存到数据库", Cause = "系统错误", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("ChangeInfo", "User") + "'>修改资料</a>页面,输入正确的信息后重新操作</li><li>联系网站管理员</li>") };
             return RedirectToAction("UserError", "Prompt", _e);
         }
     }
     else
     {
         ModelState.AddModelError("Password","密码错误!");
         return View();
     }
 }
Esempio n. 2
0
        public ActionResult MailAdd(Mail mail)
        {
            mail.FromUserName = UserController.UserName;

            if (ModelState.IsValid)
            {
                mail.IsSend ^= true;
                if (mailRsy.Add(mail))
                {
                    Notice _n = new Notice { Title = "添加邮件成功", Details = "您已经成功添加[" , DwellTime = 5, NavigationName = "收件箱", NavigationUrl = Url.Action("MailInbox", "Mail") };
                    return RedirectToAction("UserNotice", "Prompt", _n);
                }
                else
                {
                    Error _e = new Error { Title = "添加邮件失败", Details = "在添加邮件时,未能保存到数据库", Cause = "系统错误", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("MailAdd", "Mail") + "'>添加邮件</a>页面,输入正确的信息后重新操作</li><li>返回<a href='" + Url.Action("MailDefault", "Mail") + "'>邮件管理首页</a>。</li><li>联系网站管理员</li>") };
                    return RedirectToAction("ManageError", "Prompt", _e);
                }
            }
            return View(mail);
        }
Esempio n. 3
0
 public ActionResult MailDelete(int id)
 {
     bool _deleted = mailRsy.Delete(id);
     if (Request.IsAjaxRequest())
     {
         return Json(_deleted);
     }
     else
     {
         if (_deleted)
         {
             Notice _n = new Notice { Title = "删除邮件成功", Details = "您已经成功删除了该邮件!", DwellTime = 5, NavigationName = "我的邮件", NavigationUrl = Url.Action("MailInbox", "Mail") };
             return RedirectToAction("UserNotice", "Prompt", _n);
         }
         else
         {
             Error _e = new Error { Title = "删除邮件失败", Details = "在删除邮件时发生错误", Cause = "该邮件已经被删除", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("UserOwn", "Mail") + "'>我的邮件</a>页面,输入正确的信息后重新操作</li><li>返回<a href='" + Url.Action("UserDefault", "Mail") + "'>邮件管理首页</a>。</li><li>联系网站管理员</li>") };
             return RedirectToAction("ManageError", "Prompt", _e);
         }
     }
 }
Esempio n. 4
0
 public ActionResult MailEdit(Mail mail)
 {
     if (ModelState.IsValid)
     {
         var _mail = mailRsy.Find(mail.MailID);
         if (_mail == null)//邮件不存在
         {
             Error _e = new Error { Title = "邮件不存在", Details = "查询不到MailId为【" + mail.MailID.ToString() + "】的邮件", Cause = "邮件已被删除或向服务器提交邮件时数据丢失", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("UserOwn", "Mail") + "'>我的邮件</a>重新操作</li><li>返回<a href='" + Url.Action("UserDefault", "Mail") + "'>邮件管理首页</a>。</li><li>联系网站管理员</li>") };
             return RedirectToAction("ManageError", "Prompt", _e);
         }
         if (mail.SendTime != null) _mail.SendTime = mail.SendTime;
         if (mail.FromUserName != null) _mail.FromUserName = mail.FromUserName;
         if (mail.ToUserName != null) _mail.ToUserName = mail.ToUserName;
         if (mail.Title != null) _mail.Title = mail.Title;
         _mail.Content = mail.Content;
         if (mailRsy.Update(_mail))
         {
             Notice _n = new Notice { Title = "修改邮件成功", Details = "您已经成功修改了[" + mail.Title + "]邮件!", DwellTime = 5, NavigationName = "我的邮件", NavigationUrl = Url.Action("UserOwn", "Mail") };
             return RedirectToAction("UserNotice", "Prompt", _n);
         }
         else
         {
             Error _e = new Error { Title = "修改邮件失败", Details = "在修改邮件时,未能保存到数据库", Cause = "系统错误", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("UserAdd", "Mail", new { id = mail.MailID }) + "'>修改邮件</a>页面,输入正确的信息后重新操作</li><li>返回<a href='" + Url.Action("UserDefault", "Mail") + "'>邮件管理首页</a>。</li><li>联系网站管理员</li>") };
             return RedirectToAction("ManageError", "Prompt", _e);
         }
     }
     return View(mail);
 }
Esempio n. 5
0
 public ActionResult ChangePassword(UserChangePassword userChangePassword)
 {
     userRsy = new UserRepository();
     if (userRsy.Authentication(UserName, Common.Text.Sha256(userChangePassword.Password)) == 0)
     {
         var _user = userRsy.Find(UserName);
         if (_user == null)
         {
             Error _e = new Error { Title = "修改密码失败", Details = "修改密码时,系统查询不到用户信息", Cause = Server.UrlEncode("<li>用户在修改密码界面停留的时间过长,登录信息已失效。</li><li>系统错误。</li>"), Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("ChangePassword", "User") + "'>修改密码</a>页面,输入正确的信息后重新注册</li><li>联系网站管理员</li>") };
             return RedirectToAction("Error", "Prompt", _e);
         }
         _user.Password = Common.Text.Sha256(userChangePassword.NewPassword);
         if (userRsy.Update(_user))
         {
             Notice _n = new Notice { Title = "成功修改密码", Details = "您已经成功修改密码,请牢记您的新密码!", DwellTime = 5, NavigationName = "登陆页面", NavigationUrl = Url.Action("Login", "User") };
             return RedirectToAction("Notice", "Prompt", _n);
         }
         else
         {
             Error _e = new Error { Title = "修改密码失败", Details = "修改密码时,更新数据库失败!", Cause = Server.UrlEncode("<li>系统错误。</li>"), Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("ChangePassword", "User") + "'>修改密码</a>页面,输入正确的信息后重新注册</li><li>联系网站管理员</li>") };
             return RedirectToAction("Error", "Prompt", _e);
         }
     }
     else
     {
         ModelState.AddModelError("Password", "原密码不正确,请重新输入");
         return View();
     }
 }
Esempio n. 6
0
 public ActionResult Register(UserRegister userReg)
 {
     userRsy = new UserRepository();
     if (userRsy.Exists(userReg.UserName))
     {
         ModelState.AddModelError("UserName", "用户名已存在");
         return View();
     }
     User _user = userReg.GetUser();
     _user.RegTime = System.DateTime.Now;
     if (userRsy.Add(_user))
     {
         Notice _n = new Notice { Title = "注册成功", Details = "您已经成功注册,用户为:" + _user.UserName + " ,请牢记您的密码!", DwellTime = 5, NavigationName = "登陆页面", NavigationUrl = Url.Action("Login", "User") };
         return RedirectToAction("Notice", "Prompt", _n);
     }
     else
     {
         Error _e = new Error { Title = "注册失败", Details = "在用户注册时,发生了未知错误", Cause = "系统错误", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("Register", "User") + "'>注册</a>页面,输入正确的信息后重新注册</li><li>联系网站管理员</li>") };
         return RedirectToAction("Error", "Prompt", _e);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 退出系统
 /// </summary>
 /// <returns></returns>
 public ActionResult Logout()
 {
     if (Request.Cookies["User"] != null)
     {
         HttpCookie _cookie = Request.Cookies["User"];
         _cookie.Expires = DateTime.Now.AddHours(-1);
         Response.Cookies.Add(_cookie);
     }
     Notice _n = new Notice { Title = "成功退出", Details = "您已经成功退出!", DwellTime = 5, NavigationName="网站首页", NavigationUrl = Url.Action("Index", "Home") };
     return RedirectToAction("Notice", "Prompt", _n);
 }