public void StandardCustomer_Create_Succeeds()
        {
            var customer = new StandardCustomer
            {
                FirstName      = "Deividas",
                LastName       = "Brazenas",
                MonthlySalary  = 1000,
                PersonalNumber = "12345678901"
            };

            var existingCustomers = new List <Customer>
            {
                new VipCustomer
                {
                    FirstName      = "Tomas",
                    LastName       = "Drasutis",
                    MonthlySalary  = 1100,
                    PersonalNumber = "12345678101"
                },
                new StandardCustomer
                {
                    FirstName      = "Arnas",
                    LastName       = "Danaitis",
                    MonthlySalary  = 1000,
                    PersonalNumber = "12345678101"
                }
            };

            Assert.True(_customerDomainService.CanCreateCustomer(customer, existingCustomers));
        }
コード例 #2
0
        public async Task <int?> CreateCustomer(CustomerRequest customer)
        {
            var customers = await _customerDataAgent.GetAllCustomers();

            var customerObject = _customerMapper.MapToDomain(customer);

            if (_customerDomainService.CanCreateCustomer(customerObject, customers))
            {
                var createdCustomerId = await _customerDataAgent.CreateCustomer(customerObject);

                _logger.Information($"Customer created. Id - {createdCustomerId}");

                return(createdCustomerId);
            }

            return(null);
        }