public bool editMessage(int userRequesterId, int messageId, string title, string body) { if ((title == null) || (title.Equals(""))) { throw new ArgumentException(error_emptyTitle); } if (!IsValidMessage(title, body)) { throw new ArgumentException(error_wrongWords); } Message ms = findMessage(messageId); if (ms != null) { if ((!(ms.publisherID != userRequesterId)) && (!(userRequesterId != 1))) { throw new UnauthorizedAccessException("User " + userRequesterId + " has no permissions to edit the message " + messageId); } if (ms.PublisherID == userRequesterId) { ms.editMessage(title, body); saveMessageDB(); return(true); } else { throw new ArgumentException(error_callerIDnotMatch); } } throw new InvalidOperationException(error_messageIdNotFound); }
public bool editMessage(int messageId, string title, string body) { if ((title == null) || (title.Equals(""))) { throw new ArgumentException(error_emptyTitle); } Message ms = findMessage(messageId); if (ms != null) { ms.editMessage(title, body); return(true); } throw new InvalidOperationException(error_messageIdNotFound); }