public long CreatePost(CreatePostInfo info, IUnitOfWork unitOfWork = null) { // Check user permissions _forumAuthorizer.AuthorizeCreatePost(info); // Validate supplied post details _forumValidator.ValidateCreatePost(info); // Remove extraneous white space info.Message = info.Message.Trim(); // Create forum post long postId = _forumRepository.CreatePost(info, DateTime.UtcNow, unitOfWork); // Get thread details to determine whether or not notification should be sent to thread owner ForumThread thread = _forumRepository.GetThread(info.TenantId, info.ElementId, info.ThreadId, unitOfWork); if (thread.Notify && thread.UserId != info.UserId) { // Ger details of user who started thread User user = _userRepository.ReadUser(info.TenantId, thread.UserId, unitOfWork); User postUser = _userRepository.ReadUser(info.TenantId, info.UserId, unitOfWork); // Get email that will be sent to thread owner int threadPage = GetThreadPage(info.TenantId, info.ElementId, info.ThreadId, postId, unitOfWork); int? page = threadPage == 0 ? (int?)null : threadPage + 1; Email email = _forumConfigurationService.GetCreatePostEmail(user.Email, user.Alias, postId, page, thread.Subject, postUser.Alias); // Send email _emailService.SendEmail(email); } // Return newly allocated post identifier return(postId); }