public void PublishMessage(Message message) { using (var databaseTransaction = _databaseTransactionService.BeginTransaction()) { try { string userNameToReply = message.Mind.GetUserNameToReply(); var mentionedUserNames = message.Mind.GetUserNames(); _userMessageRepository.PublishMessage(message.Id, userNameToReply, mentionedUserNames); _messageHashtagService.CreateHashtags(message); _messageMentionService.CreateMentions(message); _searchService.AddMessageToIndex(message); _messageRepository.Update(message); _unitOfWork.Commit(); databaseTransaction.Commit(); } catch (Exception) { databaseTransaction.Rollback(); throw; } } }