public void UpdatePost(UpdatePostInfo info, IUnitOfWork unitOfWork = null) { // Check user permissions _forumAuthorizer.AuthorizeUpdatePost(info); // Validate supplied post details _forumValidator.ValidateUpdatePost(info); // Remove extraneous white space info.Message = info.Message.Trim(); // Update forum post _forumRepository.UpdatePost(info, DateTime.UtcNow, unitOfWork); // Get thread details to determine whether or not notification should be sent to thread owner TODO: Implement this ForumThread thread = _forumRepository.GetThread(info.TenantId, info.ElementId, info.ThreadId, unitOfWork); if (thread.Notify && thread.UserId != info.UserId) { #if false // Get email that will be sent to thread owner Email email = _updatePostEmailFactory.CreateEmail(); // Send email _sendEmailService.SendEmail(email); #endif } }
public void AuthorizeUpdatePost(UpdatePostInfo info) { // Retrieve forum thread details ForumPost post = _forumRepository.GetPost(info.TenantId, info.ElementId, info.ThreadId, info.PostId); // User can update post if they created post or if they are an administrator _functionAuthorizer.Authorize(new UserFunction { Function = GetUpdatePostFunction(info.UserId, post.UserId), UserId = info.UserId, TenantId = info.TenantId }); }
private FormResult PostUpdatePostForm(Form form) { // Get logged on user details long tenantId = _authenticationService.TenantId; long userId = _authenticationService.GetCurrentUser().User.UserId; // Get page, element and thread identifiers string[] parts = form.Context.Split('|'); long pageId = Convert.ToInt64(parts[1]); long elementId = Convert.ToInt64(parts[2]); long threadId = Convert.ToInt64(parts[3]); long postId = Convert.ToInt64(parts[4]); // Get existing thread details ForumThread forumThread = _forumService.GetThread(tenantId, elementId, threadId); // Get information required to update post UpdatePostInfo info = new UpdatePostInfo { ElementId = elementId, Message = ((MultiLineTextField)form.Fields["message"]).Value, PostId = postId, TenantId = tenantId, ThreadId = threadId, UserId = userId }; // Update post _forumService.UpdatePost(info); // Get thread page that new post is on int page = _forumService.GetThreadPage(tenantId, info.ElementId, info.ThreadId, postId); // Return form result with no errors string status = _forumUrlService.GetThreadUrl(pageId, threadId, forumThread.Subject, page); return(_formHelperService.GetFormResult(status)); }
public void UpdatePost(UpdatePostInfo info, DateTime updated, IUnitOfWork unitOfWork = null) { IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork); try { string sql = _sqlManager.GetSql("Sql.UpdateForumPost.sql"); dbm.SetSQL(sql); dbm.AddParameter("@TenantId", FieldType.BigInt, info.TenantId); dbm.AddParameter("@ElementId", FieldType.BigInt, info.ElementId); dbm.AddParameter("@ThreadId", FieldType.BigInt, info.ThreadId); dbm.AddParameter("@PostId", FieldType.BigInt, info.PostId); dbm.AddParameter("@Message", FieldType.NVarChar, -1, info.Message); dbm.AddParameter("@Updated", FieldType.DateTime, updated); dbm.ExecuteNonQuery(); } finally { if (unitOfWork == null) { dbm.Dispose(); } } }
public void ValidateUpdatePost(UpdatePostInfo info) { _modelValidator.Validate(info); }