Exemplo n.º 1
0
 public bool Add(int id, int userId)
 {
     var model = new ArticleLike
     {
         DataId=id,
         CreateTime=DateTime.Now,
         IsDel=false,
         UserId=userId
     };
     return _articleLikeRepository.Insert(model) > 0;
 }
Exemplo n.º 2
0
 public bool Like(int id, int userId)
 {
     if (userId == 0 || _articleLikeRepository.Exist(t => t.DataId == id && t.UserId == userId && t.IsComment))
         return false;
     var model = new ArticleLike
     {
         DataId = id,
         IsComment = true,
         CreateTime = DateTime.Now,
         IsDel = false,
         UserId = userId
     };
     var result = _articleLikeRepository.Insert(model) > 0;
     if (result)
         return _acticleCommentRepository.UpdateLikeCount(id);
     return false;
 }