public void UpdateThread(UpdateThreadInfo info, DateTime updated, IUnitOfWork unitOfWork = null) { IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork); try { string sql = _sqlManager.GetSql("Sql.UpdateForumThread.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("@Subject", FieldType.NVarChar, 256, info.Subject); dbm.AddParameter("@Message", FieldType.NVarChar, -1, info.Message); dbm.AddParameter("@Notify", FieldType.Bit, info.Notify); dbm.AddParameter("@Updated", FieldType.DateTime, updated); dbm.ExecuteNonQuery(); } finally { if (unitOfWork == null) { dbm.Dispose(); } } }
private FormResult PostUpdateThreadForm(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]); // Get information required to update existing thread UpdateThreadInfo info = new UpdateThreadInfo { ElementId = elementId, Message = ((MultiLineTextField)form.Fields["message"]).Value, Notify = ((BooleanField)form.Fields["notify"]).Value, Subject = ((TextField)form.Fields["subject"]).Value, TenantId = tenantId, ThreadId = threadId, UserId = userId }; // Update existing thread _forumService.UpdateThread(info); // Return form result with no errors string status = _forumUrlService.GetThreadUrl(pageId, threadId, info.Subject); return(_formHelperService.GetFormResult(status)); }
public void AuthorizeUpdateThread(UpdateThreadInfo info) { // Retrieve forum thread details ForumThread thread = _forumRepository.GetThread(info.TenantId, info.ElementId, info.ThreadId); // User can update thread if they created thread or if they are an administrator _functionAuthorizer.Authorize(new UserFunction { Function = GetUpdateThreadFunction(info.UserId, thread.UserId), UserId = info.UserId, TenantId = info.TenantId }); }
public void UpdateThread(UpdateThreadInfo info, IUnitOfWork unitOfWork = null) { // Check user permissions _forumAuthorizer.AuthorizeUpdateThread(info); // Validate supplied thread details _forumValidator.ValidateUpdateThread(info); // Remove extraneous white space info.Subject = info.Subject.Trim(); info.Message = info.Message.Trim(); // Update forum thread _forumRepository.UpdateThread(info, DateTime.UtcNow, unitOfWork); }
public void ValidateUpdateThread(UpdateThreadInfo info) { _modelValidator.Validate(info); }