public void DeleteuserMessage(int messageId)
        {
            var message = GetUserMessageByMessageId(messageId);

            if (message == null)
            {
                throw new MessageNotFoundException(MessagingConstants.MessageNotFoundInfo(messageId));
            }

            //remove the message
            _context.UserMessages
            .Remove(message);

            // confirm changes
            _context.SaveChanges();
        }
Exemplo n.º 2
0
 public void UpdateMessageReadStatus(int messageId, bool newReadStatus)
 {
     try
     {
         _repository.UpdateMessageReadStatus(messageId, newReadStatus);
     }
     catch (MessageNotFoundException ex)
     {
         Log.Error(ex, MessagingConstants.MessageNotFoundInfo(messageId));
         throw;
     }
     catch (Exception ex)
     {
         Log.Error(ex, MessagingConstants.MessageSaveError(messageId));
         throw;
     }
 }
        public void UpdateMessageReadStatus(int messageId, bool newReadStatus)
        {
            var message = GetUserMessageByMessageId(messageId);

            if (message == null)
            {
                throw new MessageNotFoundException(MessagingConstants.MessageNotFoundInfo(messageId));
            }

            //Update flag
            _context.UserMessages
            .Where(a => a.MessageId == messageId)
            .FirstOrDefault()
            .Read = newReadStatus;

            // save changes
            _context.SaveChanges();
        }
Exemplo n.º 4
0
 public void DeleteUserMessage(int messageId)
 {
     try
     {
         _repository.DeleteuserMessage(messageId);
     }
     catch (MessageNotFoundException ex)
     {
         Log.Error(ex, MessagingConstants.MessageNotFoundInfo(messageId));
         throw;
     }
     catch (DbUpdateException ex)
     {
         Log.Error(ex, MessagingConstants.CANNOT_DELETE_MESSAGE);
     }
     catch (Exception ex)
     {
         Log.Error(ex, MessagingConstants.MessageDeleteError(messageId));
         throw;
     }
 }