コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
 public void Delete(Guid messageId)
 {
     using (var databaseTransaction = _databaseTransactionService.BeginTransaction())
     {
         try
         {
             _messageRepository.DeleteMessage(messageId);
             databaseTransaction.Commit();
         }
         catch (Exception)
         {
             databaseTransaction.Rollback();
             throw;
         }
     }
 }