Example #1
0
        public ActionResult UpdateArtile(ArticleView article)
        {
            try
            {
                var item = Article.Find(article.Id);
                if (item != null)
                {
                    item.Name = article.Name;
                    item.Order = article.Order;
                    item.ParentId = article.ParentId;
                    item.Content = article.Content;
                    item.Save();
                    return this.Json(new ActionResultStatus(), JsonRequestBehavior.AllowGet);
                }

                return this.Json(new ActionResultStatus(10, "文章不存在!"), JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return this.Json(new ActionResultStatus(ex), JsonRequestBehavior.AllowGet);
            }
        }
Example #2
0
 public ActionResult CreateArticle(ArticleView article)
 {
     try
     {
         var item = new Article() { Category = Category.Articles, Name = article.Name, Order = article.Order, ParentId = article.ParentId, Content = article.Content };
         item.Create();
         return this.Json(new ActionResultStatus(), JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return this.Json(new ActionResultStatus(ex), JsonRequestBehavior.AllowGet);
     }
 }