Пример #1
0
		public PostEdit GetPostForEdit(Post post, User user, bool isMobile)
		{
			if (post == null)
				throw new ArgumentNullException("post");
			if (user == null)
				throw new ArgumentNullException("user");
			var profile = _profileRepository.GetProfile(user.UserID);
			var postEdit = new PostEdit(post) { IsPlainText = profile.IsPlainText };
			if (profile.IsPlainText || isMobile)
			{
				postEdit.FullText = _textParsingService.HtmlToForumCode(post.FullText);
				postEdit.IsPlainText = true;
			}
			else
				postEdit.FullText = _textParsingService.HtmlToClientHtml(post.FullText);
			return postEdit;
		}
Пример #2
0
		public void EditPost(Post post, PostEdit postEdit, User editingUser)
		{
			var oldText = post.FullText;
			post.Title = _textParsingService.EscapeHtmlAndCensor(postEdit.Title);
			if (postEdit.IsPlainText)
				post.FullText = _textParsingService.ForumCodeToHtml(postEdit.FullText);
			else
				post.FullText = _textParsingService.ClientHtmlToHtml(postEdit.FullText);
			post.ShowSig = postEdit.ShowSig;
			post.LastEditTime = DateTime.UtcNow;
			post.LastEditName = editingUser.Name;
			post.IsEdited = true;
			_postRepository.Update(post);
			_moderationLogService.LogPost(editingUser, ModerationType.PostEdit, post, postEdit.Comment, oldText);
		}
Пример #3
0
		public ActionResult Edit(int id, PostEdit postEdit)
		{
			var post = _postService.Get(id);
			if (!User.IsPostEditable(post))
				return this.Forbidden("Forbidden", null);
			_postService.EditPost(post, postEdit, this.CurrentUser());
			return RedirectToAction("PostLink", new { id = post.PostID });
		}