Exemplo n.º 1
0
        public async Task RunCommand(
            [NServiceBusTrigger(Endpoint = QueueNames.SendInvitationCommand)] SendInvitationCommand sendInvitationCommand,
            ILogger log)
        {
            try
            {
                var response = await _api.SendInvitation(sendInvitationCommand.ClientId, new SendInvitationRequest
                {
                    Email              = sendInvitationCommand.Email,
                    GivenName          = sendInvitationCommand.GivenName,
                    FamilyName         = sendInvitationCommand.FamilyName,
                    SourceId           = sendInvitationCommand.SourceId,
                    Callback           = new Uri(sendInvitationCommand.Callback),
                    UserRedirect       = new Uri(sendInvitationCommand.UserRedirect),
                    OrganisationName   = sendInvitationCommand.OrganisationName,
                    ApprenticeshipName = sendInvitationCommand.ApprenticeshipName,
                    Inviter            = null
                });

                log.LogInformation(
                    $"Completed {typeof(SendInvitationCommand)} InvitationId : {response?.InvitationId} Invited : {response?.Invited}, Message : { response?.Message}");
            }
            catch (Exception e)
            {
                log.LogError($"Errored when processing {typeof(SendInvitationCommand)}", e);
                throw;
            }
        }
 public void GivenWeHaveCreatedAValidSendInvitationCommand()
 {
     _message = _fixture.Build <SendInvitationCommand>()
                .With(x => x.ClientId, _clientId)
                .With(x => x.Email, _userEmail)
                .With(x => x.UserRedirect, "https://test.com/")
                .With(x => x.Callback, "https://test.com/")
                .Create();
 }
Exemplo n.º 3
0
        public IHttpActionResult SendInvitation([FromBody] dynamic model)
        {
            var originatorId     = (string)model.OriginatorId;
            var targetUserId     = (string)model.TargetUserId;
            var invitationLetter = (string)model.InvitationLetter;

            var command = new SendInvitationCommand
            {
                OriginatorId     = Guid.Parse(originatorId),
                TargetUserId     = Guid.Parse(targetUserId),
                InvitationLetter = invitationLetter
            };

            this.CommandSender.Publish(command);
            return(Ok());
        }