Exemplo n.º 1
0
        public void TestDtoToCustomer()
        {
            AddressDTO addressDto = new AddressDTO()
            {
                Id = 1, AddressLine1 = "FakeStreet", PostalCode = "FakePostalCode", City = "FakeCity", Phone = "FakePhone", Email = "FakeEmail", Version = 0
            };
            CustomerDTO dto = new CustomerDTO()
            {
                Id = 1, Name = "FakeUsername", FirstName = "FakeFirstname", Version = 1
            };

            dto.Addresses.Add(addressDto);
            Assert.AreEqual(true, dto.IsValid);
            Assert.AreEqual(true, addressDto.IsValid);

            Customer customer = CustomerAdapter.DtoToCustomer(dto);

            Assert.AreEqual <int>(dto.Id, customer.CustomerId);
            Assert.AreEqual <string>(dto.Name, customer.Name);
            Assert.AreEqual <string>(dto.FirstName, customer.FirstName);
            Assert.AreEqual(dto.Version, customer.Version);
            Assert.AreEqual(true, customer.IsValid);

            //Assert.AreEqual<int>(dto.Addresses.Count(), customer.Addresses.Count());
            //Assert.AreEqual(true, address.IsValid);
        }
Exemplo n.º 2
0
        public StoreCustomerResponse StoreCustomer(StoreCustomerRequest request)
        {
            StoreCustomerResponse     response = new StoreCustomerResponse();
            CustomerBusinessComponent bc       = DependencyInjectionHelper.GetCustomerBusinessComponent();

            Customer customer = CustomerAdapter.DtoToCustomer(request.Customer);
            IEnumerable <ChangeItem> changeItems = CustomerAdapter.GetChangeItems(request.Customer, customer);

            response.CustomerId = bc.StoreCustomer(customer, changeItems);

            return(response);
        }
Exemplo n.º 3
0
        public StoreCustomerResponse StoreCustomer(StoreCustomerRequest request)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                throw new FaultException <NotAuthenticatedFault>(new NotAuthenticatedFault());
            }
            StoreCustomerResponse     response = new StoreCustomerResponse();
            CustomerBusinessComponent bc       = DependencyInjectionHelper.GetCustomerBusinessComponent();
            Customer customer = CustomerAdapter.DtoToCustomer(request.Customer);
            IEnumerable <ChangeItem> changeItems = CustomerAdapter.GetChangeItems(request.Customer, customer);

            response.CustomerId = bc.StoreCustomer(customer, changeItems);

            return(response);
        }