Beispiel #1
0
        public override void ProcessMessage(ParsedMessage parsedMessage)
        {
            base.ProcessMessage(parsedMessage);

            var postComment = _postCommentRepository.Create();

            postComment.Title  = parsedMessage["TITLE"];
            postComment.Body   = parsedMessage.Body;
            postComment.Author = parsedMessage["AUTHOR"];
            if (parsedMessage["POSTID"] != null)
            {
                postComment.Post = _postRepository.Get(parsedMessage["POSTID"]);
            }
            if (parsedMessage["EMAIL"] != null)
            {
                postComment.Email = parsedMessage["EMAIL"];
            }
            if (parsedMessage["WEBSITE"] != null)
            {
                postComment.Website = parsedMessage["WEBSITE"];
            }
            postComment.PublishDate = ParseDateTime(parsedMessage);

            _postCommentRepository.Save(postComment);

            _postCommentRepository.SubmitChanges();
        }
Beispiel #2
0
        private static string CreatePostComment(IPostCommentRepository repository, string author, string title, Uri website, MailAddress email, string body)
        {
            var postComment = repository.Create();

            postComment.Author  = author;
            postComment.Title   = title;
            postComment.Website = website == null ? null : website.ToString();
            postComment.Body    = body;
            postComment.Email   = email == null ? null : email.Address;

            repository.Save(postComment);

            repository.SubmitChanges();

            return(postComment.ID);
        }
Beispiel #3
0
        private PostComment GetPostComment(EditMode editMode, string id, string postId)
        {
            switch (editMode)
            {
            case EditMode.Add:
                var post = postId != null?LoadPost(postId) : null;

                var postComment = _postCommentRepository.Create();
                postComment.Post = post;
                return(postComment);

            case EditMode.Edit:
                return(_postCommentRepository.Get(id));

            default:
                throw new ArgumentException(String.Format("Unknown EditMode '{0}'.", editMode), "editMode");
            }
        }