public Task <MessageCreatedDto> Handle(CreateQueueCommand request, CancellationToken cancellationToken) { var routingQueue = _messagePublisher.CreateMessage(request.QueueName, request.CompanyName); return(Task.FromResult(new MessageCreatedDto { RoutingKey = routingQueue })); }
public Result <long> PublishCreateOrganizationUser(int organizationUserId, int userType, int organizationId, string transactionId) { // need to make sure the org user actually exists var organizationUserData = organizationUserRepository.GetOrganizationUser(organizationUserId, userType, organizationId); if (organizationUserData == null) { return(new Result <long>(OrganizationUserServiceErrors.InvalidOrganizationUserId())); } // need to get a hold of the OrgUser metadata var profileData = profileRepository.GetProfile(organizationUserData.ProfileId, organizationId); var organizationUserRoles = roleRepository.GetOrganizationUserRoles(organizationUserId, organizationId); var roles = string.Empty; if (organizationUserRoles.Roles.Count > 0) { roles = JsonConvert.SerializeObject(organizationUserRoles.Roles); } // need to send the domain event to potential interested subscribers var message = publisher.CreateMessage(new OrganizationUserAddedDomainEvent { TransactionId = transactionId, UserType = userType, OrganizationUserId = organizationUserId, OrganizationId = organizationUserData.OrganizationId, UserId = organizationUserData.UserId, Username = organizationUserData.Username, FirstName = organizationUserData.FirstName, LastName = organizationUserData.LastName, Email = organizationUserData.Email, IsActive = organizationUserData.IsActive, CreatedAt = organizationUserData.CreatedAt, IsLocked = organizationUserData.IsLocked, IsPendingActivation = organizationUserData.IsPendingActivation, Profile = new Dictionary <int, string>(profileData.ProfileValues.Select(p => new KeyValuePair <int, string>(p.ProfileParameterId, p.Value))), Roles = roles // RelatedOrganizationUsers = TBD }); publisher.Publish(message); return(new Result <long>(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())); }