Example #1
0
 public void AddArticle(ArticleDto articleDto)
 {
     try
     {
         Article articles = _mapper.Map <Article>(articleDto);
         Logger.Info("--------转换了一条Article信息:" + JsonHelper.ObjectToJSON(articles));
         Article article =
             new Article().CreateArticle(articles.Title, articles.Ctid, articles.Author, articles.Img, articles.Content, articles.Status);
         _articleRep.Add(article);
         _unitOfWork.Commit();
         Logger.Info("--------添加了一条Article信息:" + JsonHelper.ObjectToJSON(article));
     }
     catch (Exception e)
     {
         Logger.Error("--------添加了Article信息出错:" + e);
     }
 }
Example #2
0
        public bool Add(ArticleDto dto)
        {
            var article = new Article()
            {
                AddTime     = DateTime.Now,
                BrowseCount = 55,
                CateId      = SnowflakeId.GetID(),
                Content     = "xxxxxxxxxxxxxxxxxxx",
                Description = "xxxxxxxxxxxxxxxxxxx",
                Status      = 0,
                ThumbnailId = SnowflakeId.GetID(),
                Title       = "asfasfas",
                Tag         = "xx",
                UpdateTime  = DateTime.Now,
                UserId      = SnowflakeId.GetID()
            };

            _articleRep.Add(article);
            return(_unitOfWork.SaveChange() > 0);
        }
Example #3
0
 public int Updata(ArticleDto dto)
 {
     return(_unitOfWork.SaveChange());
 }