示例#1
0
        public IEnumerable <SocialComment> SaveComment(SocialComment comment)
        {
            if (null == comment)
            {
                throw new ArgumentNullException("comment");
            }

            if (comment.Delete)
            {
                if (Guid.Empty == comment.Identifier)
                {
                    throw new ArgumentException("Identifier");
                }
            }
            else
            {
                if (Guid.Empty == comment.ReferenceIdentifier)
                {
                    throw new ArgumentException("Reference Identifier");
                }

                if (string.IsNullOrWhiteSpace(comment.Comment))
                {
                    throw new ArgumentException("Comment must be specified");
                }
            }
            comment.UserIdentifier = User.Identifier();
            var newComment = this.socialCore.SaveComment(comment);

            emailCore.NewsFeedComment(newComment);

            return(null != newComment?this.socialCore.SearchComment(comment.UserIdentifier, newComment.ReferenceIdentifier) : null);
        }
示例#2
0
        public IHttpActionResult SaveComment(SecuredSocialComment comment)
        {
            if (auth.IsNotValid(comment))
            {
                return(base.StatusCode(HttpStatusCode.Unauthorized));
            }

            if (null == comment)
            {
                return(this.BadRequest("comment"));
            }

            if (comment.Delete)
            {
                if (Guid.Empty == comment.Identifier)
                {
                    return(this.BadRequest("Identifier"));
                }
            }
            else
            {
                if (Guid.Empty == comment.ReferenceIdentifier)
                {
                    return(this.BadRequest("Reference Identifier"));
                }

                if (string.IsNullOrWhiteSpace(comment.Comment))
                {
                    return(this.BadRequest("Comment must be specified"));
                }
            }

            comment.UserIdentifier = auth.Device.UserIdentifier;
            var newComment = this.socialCore.SaveComment(comment);

            emailCore.NewsFeedComment(newComment);

            var results = null != newComment?this.socialCore.SearchComment(comment.UserIdentifier, newComment.ReferenceIdentifier) : null;

            var comments = results.Select(r => ApiComment.Map(r));

            return(this.Ok <IEnumerable <ApiComment> >(comments));
        }