public async Task Handle_GivenExistCustomer_SholudBeWithOutExceptionAsync()
        {
            var command = new UpsertCustomerCommandHandler(_context);

            var existCustomer = new UpsertCustomerCommand()
            {
                Id = 1, FirstName = "saji2", LastName = "Rei", DateOfBirth = "18/06/2000", BankAccountNumber = "sadasd", Email = "*****@*****.**", PhoneNumber = "+989399158667"
            };

            var result = await command.Handle(existCustomer, CancellationToken.None);

            Assert.IsType <Unit>(result);
        }
        public async Task <IActionResult> UpsertCustomer([FromBody] UpsertCustomerRequest request, CancellationToken cancellationToken)
        {
            var command = new UpsertCustomerCommand(request.LegacyId, request.Name, request.Address,
                                                    request.PostalCode, request.State, request.Country, request.PhoneNumber);

            var result = await _commandBus.PublishAsync(command, cancellationToken);

            if (result.IsSuccess)
            {
                return(Ok(result.CustomerId));
            }

            return(StatusCode(500));
        }
예제 #3
0
        public void GivenWeHaveTheFollowingEntries(Table table)
        {
            upsertCustomer = new UpsertCustomerCommand();
            var dictionary = new Dictionary <string, string>();

            foreach (var row in table.Rows)
            {
                dictionary.Add(row[0], row[1]);
            }

            upsertCustomer.BankAccountNumber = dictionary["BankAccountNumber"];
            upsertCustomer.DateOfBirth       = dictionary["DateOfBirth"];
            upsertCustomer.Email             = dictionary["Email"];
            upsertCustomer.FirstName         = dictionary["FirstName"];
            upsertCustomer.LastName          = dictionary["LastName"];
            upsertCustomer.PhoneNumber       = dictionary["PhoneNumber"];
        }
        public async Task Handle_GivenNewCustomer_SholudBeWithOutExceptionAsync()
        {
            var command = new UpsertCustomerCommandHandler(_context);

            var newCustomer = new UpsertCustomerCommand()
            {
                FirstName         = "saji2",
                LastName          = "rei2",
                DateOfBirth       = "20/10/1990",
                Email             = "*****@*****.**",
                PhoneNumber       = "12345678/9",
                BankAccountNumber = "544"
            };

            var result = await command.Handle(newCustomer, CancellationToken.None);

            Assert.IsType <Unit>(result);
        }