示例#1
0
        public MyAppApiResult <bool> AddArticle(MyApp_Article article)
        {
            var result = new MyAppApiResult <bool>();

            try
            {
                #region
                if (String.IsNullOrEmpty(article.AritcleName) || String.IsNullOrEmpty(article.SimpleText) || article.Type == null)
                {
                    result.AddError("数据不全,请确认后提交");
                    return(result);
                }
                #endregion
                var db = new MyAppEntities();
                article.Id              = Guid.NewGuid();
                article.WriteTime       = DateTime.Now;
                article.AritcleAuthorId = Guid.NewGuid();
                db.MyApp_Article.Add(article);
                db.SaveChanges();
            }
            catch (Exception e) {
                result.AddError(e.Message);
            }
            return(result);
        }
 public MyAppApiResult <bool> addArtical(MyApp_Article article)
 {
     return(_articalService.AddArticle(article));
 }