Exemplo n.º 1
0
 /// <summary>
 /// Translates a UI CustomerModel into a data layer Customer
 /// </summary>
 /// <param name="uiLayerCustomer">A UI CustomerModel</param>
 /// <returns>A data layer Customer</returns>
 private Customer TranslateUICustomerToDataLayerCustomer(CustomerModel uiLayerCustomer)
 {
     Customer dataLayerCustomer = new Customer();
     dataLayerCustomer.CustomerId = uiLayerCustomer.CustomerId.DataValue;
     dataLayerCustomer.FirstName = uiLayerCustomer.FirstName.DataValue;
     dataLayerCustomer.LastName = uiLayerCustomer.LastName.DataValue;
     dataLayerCustomer.Email = uiLayerCustomer.Email.DataValue;
     dataLayerCustomer.HomePhoneNumber = uiLayerCustomer.HomePhoneNumber.DataValue;
     dataLayerCustomer.MobilePhoneNumber = uiLayerCustomer.MobilePhoneNumber.DataValue;
     dataLayerCustomer.Address1 = uiLayerCustomer.Address1.DataValue;
     dataLayerCustomer.Address2 = uiLayerCustomer.Address2.DataValue;
     dataLayerCustomer.Address3 = uiLayerCustomer.Address3.DataValue;
     return dataLayerCustomer;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Allows Service layer objects to be translated into
        /// UI objects
        /// </summary>
        /// <param name="cust">Service layer object</param>
        /// <returns>UI layer object</returns>
        public static CustomerModel CustomerToCustomerModel(Customer cust)
        {
            CustomerModel customerModel = new CustomerModel();
            customerModel.CustomerId.DataValue = cust.CustomerId;
            customerModel.FirstName.DataValue = String.IsNullOrEmpty(cust.FirstName) ? String.Empty : cust.FirstName.Trim();
            customerModel.LastName.DataValue = String.IsNullOrEmpty(cust.LastName) ? String.Empty : cust.LastName.Trim();
            customerModel.Email.DataValue = String.IsNullOrEmpty(cust.Email) ? String.Empty : cust.Email.Trim();
            customerModel.HomePhoneNumber.DataValue = String.IsNullOrEmpty(cust.HomePhoneNumber) ? String.Empty : cust.HomePhoneNumber.Trim();
            customerModel.MobilePhoneNumber.DataValue = String.IsNullOrEmpty(cust.MobilePhoneNumber) ? String.Empty : cust.MobilePhoneNumber.Trim();
            customerModel.Address1.DataValue = String.IsNullOrEmpty(cust.Address1) ? String.Empty : cust.Address1.Trim();
            customerModel.Address2.DataValue = String.IsNullOrEmpty(cust.Address2) ? String.Empty : cust.Address2.Trim();
            customerModel.Address3.DataValue = String.IsNullOrEmpty(cust.Address3) ? String.Empty : cust.Address3.Trim();
            //convert to UI type objects
            customerModel.Orders = new Cinch.DispatcherNotifiedObservableCollection<OrderModel>(cust.Orders.ToList().ConvertAll(
                    new Converter<Order, OrderModel>(OrderModel.OrderToOrderModel)));
            return customerModel;

        }