Ejemplo n.º 1
0
        public BaseResponse InsertComment(CommentDto comment)
        {
            comment.CannotBeNull("comment");
            var user = _commentRepository.GetUserBySocialId(comment.UserId);
            int res;
            if (user == null)
            {
               res =  _commentRepository.InsertCommentAndUser(comment);
            }
            else
            {
                res = _commentRepository.InsertComment(comment, user.IdUser);
                if (string.IsNullOrEmpty(user.Email) && comment.UserMail != null)
                {
                    user.Email = comment.UserMail;
                    _commentRepository.UpdateSocialUser(user);
                }
            }

            return new BaseResponse() { Message = res > 0 ? res.ToString() : "ko", Success = res > 0 };
        }
Ejemplo n.º 2
0
        public int InsertComment(CommentDto comment, long idUser, IDbTransaction transaction = null)
        {
            comment.CannotBeNull("comment");
                var conn = transaction != null ? transaction.Connection :  DbUtilities.Connection;

                var res = conn.Query<int>(QueryCommentStore.InsertPostComment + " " + QueryStore.LastInsertedId,
                new
                {
                    idsocialcomment = comment.IdComment,
                    idpost = comment.IdPost,
                    iduser = idUser,
                    text = comment.Comment,
                    pageurl = comment.PageUrl,
                    timestamp = DateTime.Now
                }, transaction: transaction).SingleOrDefault();

            if (transaction != null) return res;

            conn.Close();
            conn.Dispose();
            return res;
        }