Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] StartApplicationRequest request)
        {
            var command = new StartApplicationSaga
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email,
                Password  = request.Password,
                EligibilityQualifierId = request.EligibilityQualifierId,
                ProductId = request.ProductId
            };

            var commandResponse = await _bus.SendCommand <StartApplicationSagaResponse>(command);

            Log.Debug("Got response back from StartApplicationSaga");
            Log.Debug("Attempting to get a token from the identity server at " + _identityClient.EndpointUri);
            var authResult = await _identityClient.GetToken(request.Email, request.Password);

            Log.Debug("Got a response from the Identity Server");

            var response = new StartApplicationResponse
            {
                ApplicationId          = commandResponse.ApplicationId,
                FirstName              = request.FirstName,
                LastName               = request.LastName,
                Email                  = request.Email,
                Token                  = authResult.AccessToken,
                EligibilityQualifierId = request.EligibilityQualifierId,
                ProductId              = request.ProductId
            };

            return(OaoResult.Created(response.ApplicationId, response, commandResponse.Actions));
        }
Ejemplo n.º 2
0
        public void Handle(StartApplicationSaga message)
        {
            var startCommand = new StartApplication
            {
                ApplicantEmail         = message.Email,
                ApplicantFirstName     = message.FirstName,
                ApplicantLastName      = message.LastName,
                ProductId              = message.ProductId,
                EligibilityQualifierId = message.EligibilityQualifierId
            };

            Bus.Send(startCommand);

            var createUserCommand = new CreateUser
            {
                Email    = message.Email,
                Password = message.Password
            };

            Bus.Send(createUserCommand);
        }
Ejemplo n.º 3
0
        public async Task Main(string[] args)
        {
            Console.WriteLine("Hit enter to publish a message to the queue.  Type 'quit' and enter to stop");

            var timer = new Stopwatch();

            while (true)
            {
                var action = Console.ReadLine();

                if (action != null && action.Equals("quit", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                var command = new StartApplicationSaga
                {
                    FirstName = "First",
                    LastName  = "Last",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    EligibilityQualifierId = Guid.NewGuid(),
                    ProductId = Guid.NewGuid()
                };

                timer.Restart();
                var commandResponse = await _bus.SendCommand <StartApplicationSagaResponse>(command);

                timer.Stop();
                var serialized = JsonConvert.SerializeObject(commandResponse);

                Console.WriteLine(serialized);
                Console.WriteLine("Elapsed (ms): " + timer.ElapsedMilliseconds);
                Console.WriteLine();
                Console.WriteLine();
            }
        }