예제 #1
0
        public IComment CreateComment(IStory forStory, string content, DateTime at, IUser byUser, string fromIpAddress)
        {
            Check.Argument.IsNotEmpty(content, "content");
            PerformCheck(forStory, at, byUser, fromIpAddress);

            var comment = new StoryComment
            {
                Id        = Guid.NewGuid(),
                HtmlBody  = content.Trim(),
                TextBody  = content.StripHtml().Trim(),
                Story     = (Story)forStory,
                User      = (User)byUser,
                IPAddress = fromIpAddress,
                CreatedAt = at
            };

            return(comment);
        }
        public async Task <bool> CreateCommentAsync(string storyId, string content, User user)
        {
            ArgumentValidator.ThrowIfNullOrEmpty(storyId, nameof(storyId));
            ArgumentValidator.ThrowIfNullOrEmpty(content, nameof(content));
            ArgumentValidator.ThrowIfNull(user, nameof(user));

            var comment = new StoryComment
            {
                AuthorId  = user.Id,
                StoryId   = storyId,
                Comment   = content,
                CreatedOn = DateTime.UtcNow
            };

            await this.storyCommentRepository.AddAsync(comment);

            var result = await this.storyCommentRepository.SaveChangesAsync();

            return(result != 0);
        }
예제 #3
0
 public CommentFixture()
 {
     _comment = new StoryComment();
 }