Beispiel #1
0
 /// <summary>
 /// Ensures each customer property except id are equal in both customer objects
 /// </summary>
 internal void CompareCustomers(CustomerDataTransferObject customerInfo, CustomerEntity customerEntity)
 {
     foreach (var item in customerInfo.GetType().GetTypeInfo().GetProperties())
     {
         var customerEntityPropertyInfo = GetCustomerEntityPropertyInfo(item);
         Assert.Equal(customerEntityPropertyInfo.GetValue(customerEntity), item.GetValue(customerInfo));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Updates an existing customer's information with the customerDataTransferObject
        /// </summary>
        private void UpdateCustomerInfo(CustomerEntity customerEntity,
                                        CustomerDataTransferObject customerDataTransferObject)
        {
            if (customerEntity == null ||
                customerDataTransferObject == null ||
                !customerDataTransferObject.ValidateCustomerDataTransferObject())
            {
                throw new ArgumentException();
            }

            foreach (var item in customerDataTransferObject.GetType().GetTypeInfo().GetProperties())
            {
                var desinationPropertyInfo = typeof(CustomerEntity).GetProperty(item.Name);
                desinationPropertyInfo?.SetValue(customerEntity, item.GetValue(customerDataTransferObject));
            }
        }