示例#1
0
		public async Task<Page> AddCommentAsync(string title, string content, IPrincipal user, Page page)
		{
			if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(content) ||
				user == null || page == null)
				throw new ArgumentException();

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

			await _db.SaveChangesAsync();
			SortComments(ref page);
			return page;
		}
示例#2
0
		public async Task DeleteCommentAsync(PageComment comment)
		{
			if (comment == null)
				throw new ArgumentNullException();

			_db.PageComments.Remove(comment);
			await _db.SaveChangesAsync();
		}
		public CommentSubmittionModel(string pageId)
		{
			Comment = new PageComment();
			PageId = pageId;
		}