public async Task SendAsync(Message message) { if (!StringUtils.hasText(message.FromUserId)) { throw new MessageServiceException("Invalid source"); } if (message.To == null || !StringUtils.hasText(message.To.Id)) { throw new MessageServiceException("Invalid source"); } if (String.Equals(message.To.Id, message.FromUserId, StringComparison.InvariantCultureIgnoreCase)) { throw new MessageServiceException("source equals destination"); } if (!StringUtils.hasText(message.Body)) { throw new MessageServiceException("Invalid body"); } if (message.To.Type == DestinationType.User) { if (await userRepository.FindByIdAsync(message.To.Id) == null) { throw new MessageServiceException("Destination User Not Found"); } } await messageSender.SendAync(message); }