bool MatchFilter(CommentMessage message, string filter)
 {
     return(message.body.ToLowerInvariant().Contains(filter) ||
            message.from.ToLowerInvariant().Contains(filter) ||
            message.attachedObjects.Any(o => o.name.ToLowerInvariant().Contains(filter)) ||
            message.URL.ToLowerInvariant().Contains(filter)
            );
 }
Ejemplo n.º 2
0
        public override Task <BoolMessage> SubmitComment(CommentMessage commentMessage, ServerCallContext context)
        {
            bool added = MessageCommentToEntityComment(commentMessage).AddComment();

            return(Task.FromResult(new BoolMessage
            {
                Value = added
            }));
        }
Ejemplo n.º 3
0
 public Comment MessageCommentToEntityComment(CommentMessage commentMessage)
 {
     return(new Comment
     {
         Id = commentMessage.Id,
         Text = commentMessage.Text,
         PostPostId = commentMessage.PostPostId,
         Post = MessagePostToEntityPost(commentMessage.Post)
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts to comment message.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <returns></returns>
        private CommentMessage ConvertToCommentMessage(Comment comment)
        {
            CommentMessage message = new CommentMessage
            {
                Author      = comment.Author,
                AuthorEmail = comment.AuthorEmail,
                AuthorUrl   = comment.AuthorUrl,
                Body        = comment.Body,
                UserAgent   = comment.UserAgent,
                UserIP      = comment.UserIp
            };

            return(message);
        }
Ejemplo n.º 5
0
        public CommentMessage CommentAdd(CommentMessage commentAdd, int Id)
        {
            var obj = db.postMessageData.Find(Id);

            if (obj.Comment == null)
            {
                obj.Comment = new List <CommentMessage>()
                {
                    commentAdd
                };
            }
            else
            {
                obj.Comment.Add(commentAdd);
            }

            db.postMessageData.Update(obj);
            db.SaveChanges();
            return(commentAdd);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Execute(CreateCommentCommand command)
        {
            Momento momento = _database.SingleOrDefault <Momento>(c => c.Id == command.MomentoId);
            Comment comment = new Comment();

            comment.Author      = comment.Author;
            comment.AuthorEmail = command.AuthorEmail;
            comment.AuthorUrl   = command.AuthorUrl;
            comment.Body        = comment.Body;
            comment.UserAgent   = command.UserAgent;
            comment.UserIp      = command.UserIp;

            momento.AddComment(comment);

            _database.Add(momento);
            _database.Save();

            CommentMessage commentMessage = ConvertToCommentMessage(comment);

            _bus.Send(commentMessage);
        }
Ejemplo n.º 7
0
        public override Task <NoParamsMessage> DeleteComment(CommentMessage commentMessage, ServerCallContext context)
        {
            new Comment().DeleteComment(commentMessage.Id);

            return(Task.FromResult(new NoParamsMessage()));
        }