Exemplo n.º 1
0
		public async Task<Post> AddComment(string title, string content, IPrincipal user, Post post)
		{
			if (String.IsNullOrWhiteSpace(title))
				title = "Untitled";
            if (String.IsNullOrEmpty(title) | String.IsNullOrEmpty(content) | user == null | post == null)
                throw new ArgumentNullException();

			var appuser = await _userService.GetUserByIPrincipalAsync(user);
			var comment = new PostComment
			{
				Author = appuser,
				Content = content.FilterHtml(),
				Id = Guid.NewGuid(),
				OriginalContent = post,
				Posted = DateTime.Now,
				Title = HttpUtility.HtmlEncode(title)
			};
			post.Comments.Add(comment);

			await _db.SaveChangesAsync();
			SortComments(ref post);
			return post;
		}
Exemplo n.º 2
0
		public async Task DeleteComment(PostComment comment)
		{
            if (comment == null)
                throw new ArgumentNullException();

			_db.PostComments.Remove(comment);
			await _db.SaveChangesAsync();
		}
		public CommentSubmittionModel(string postId)
		{
			Comment = new PostComment();
			PostId = postId;
		}