Example #1
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);
        }
Example #2
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);
 }