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) ); }
public override Task <BoolMessage> SubmitComment(CommentMessage commentMessage, ServerCallContext context) { bool added = MessageCommentToEntityComment(commentMessage).AddComment(); return(Task.FromResult(new BoolMessage { Value = added })); }
public Comment MessageCommentToEntityComment(CommentMessage commentMessage) { return(new Comment { Id = commentMessage.Id, Text = commentMessage.Text, PostPostId = commentMessage.PostPostId, Post = MessagePostToEntityPost(commentMessage.Post) }); }
/// <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); }
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); }
/// <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); }
public override Task <NoParamsMessage> DeleteComment(CommentMessage commentMessage, ServerCallContext context) { new Comment().DeleteComment(commentMessage.Id); return(Task.FromResult(new NoParamsMessage())); }