Ejemplo n.º 1
0
        public ActionResult Add(T_Articles article)
        {
            var msg = new Message();
            var currentUser = UserService.GetModal(a => a.username.Equals(User.Identity.Name));

            if (article == null || string.IsNullOrEmpty(article.title) || article.cateid <= 0 || string.IsNullOrEmpty(article.body))
            {
                msg.code = 0;
                msg.body = "请确认信息的完整性";
            }
            else if (currentUser.type == 0)
            {
                msg.code = 0;
                msg.body = "您的权限不足";
            }
            else
            {
                article.title = Encoder.HtmlEncode(article.title);
                article.body = Encoder.HtmlEncode(article.body);
                article.from = Encoder.HtmlEncode(article.from);
                article.author = Encoder.HtmlEncode(article.author);
                article.createtime = DateTime.Now;
                article.uid = currentUser.id;

                var result = ArticleService.Insert(article);

                if (result)
                {

                    msg.code = 1;
                    msg.body = "添加成功";
                }
                else
                {

                    msg.code = 0;
                    msg.body = "添加失败,请联系管理员";
                }
            }

            return Json(msg);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 创建新的 T_Articles 对象。
 /// </summary>
 /// <param name="id">id 属性的初始值。</param>
 /// <param name="title">title 属性的初始值。</param>
 /// <param name="body">body 属性的初始值。</param>
 /// <param name="createtime">createtime 属性的初始值。</param>
 public static T_Articles CreateT_Articles(global::System.Int32 id, global::System.String title, global::System.String body, global::System.DateTime createtime)
 {
     T_Articles t_Articles = new T_Articles();
     t_Articles.id = id;
     t_Articles.title = title;
     t_Articles.body = body;
     t_Articles.createtime = createtime;
     return t_Articles;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 用于向 T_Articles EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToT_Articles(T_Articles t_Articles)
 {
     base.AddObject("T_Articles", t_Articles);
 }