예제 #1
0
        public Customer GetCustomerById(string id)
        {
            OrdersManagementDataSet.CustomersRow customerRow = repository.Customers.FindByCustomerId(id);
            if (customerRow == null)
            {
                return(null);
            }

            return(TranslateFromCustomerRowToCustomerEntity(customerRow));
        }
예제 #2
0
        private static Customer TranslateFromCustomerRowToCustomerEntity(OrdersManagementDataSet.CustomersRow customersRow)
        {
            Customer customer = new Customer();

            customer.Address     = customersRow.IsAddressNull() ? null : customersRow.Address;
            customer.City        = customersRow.IsCityNull() ? null : customersRow.City;
            customer.CompanyName = customersRow.CompanyName;
            customer.CustomerId  = customersRow.CustomerId;
            customer.PostalCode  = customersRow.IsPostalCodeNull() ? null : customersRow.PostalCode;
            customer.Region      = customersRow.IsRegionNull() ? null : customersRow.Region;
            return(customer);
        }
 private void AddCustomer(OrdersManagementDataSet ds, string customerId, string companyName)
 {
     OrdersManagementDataSet.CustomersRow row = ds.Customers.NewCustomersRow();
     row.CustomerId  = customerId;
     row.CompanyName = companyName;
     row.City        = string.Empty;
     row.Region      = string.Empty;
     row.PostalCode  = string.Empty;
     row.Address     = string.Empty;
     ds.Customers.AddCustomersRow(row);
     ds.AcceptChanges();
 }
 private void AddCustomer(OrdersManagementDataSet ds, string customerId, string companyName, string city, string state, string zipCode, string address)
 {
     OrdersManagementDataSet.CustomersRow row = ds.Customers.NewCustomersRow();
     row.CustomerId  = customerId;
     row.CompanyName = companyName;
     row.City        = city;
     row.Region      = state;
     row.PostalCode  = zipCode;
     row.Address     = address;
     ds.Customers.AddCustomersRow(row);
     ds.AcceptChanges();
 }
        public void CanReadAllCustomerProperties()
        {
            OrdersManagementDataSet ds = new OrdersManagementDataSet();

            OrdersManagementDataSet.CustomersRow row = ds.Customers.NewCustomersRow();
            row.CustomerId  = "42";
            row.Address     = "My Address";
            row.City        = "My City";
            row.CompanyName = "My Company";
            row.PostalCode  = "12345";
            row.Region      = "My Region";
            ds.Customers.AddCustomersRow(row);
            ds.Customers.AcceptChanges();
            CustomerService customerService = new CustomerService(ds);

            Customer customer = customerService.GetCustomerById("42");

            Assert.IsNotNull(customer);
            Assert.AreEqual("My Address", customer.Address);
            Assert.AreEqual("My City", customer.City);
            Assert.AreEqual("My Company", customer.CompanyName);
            Assert.AreEqual("12345", customer.PostalCode);
            Assert.AreEqual("My Region", customer.Region);
        }