/// <summary>
		/// Patch CatalogBase type
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this PaymentEntity source, PaymentEntity target)
		{
			if (target == null)
				throw new ArgumentNullException("target");

			var patchInjection = new PatchInjection<PaymentEntity>(x => x.Amount, x => x.PaymentGatewayCode);
			target.InjectFrom(patchInjection, source);

			if (!source.Addresses.IsNullCollection())
			{
				source.Addresses.Patch(target.Addresses, new AddressComparer(), (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
			}
		}
		public static PaymentEntity ToDataModel(this Payment payment)
		{
			if (payment == null)
				throw new ArgumentNullException("payment");

			var retVal = new PaymentEntity();
			retVal.InjectFrom(payment);

			retVal.Currency = payment.Currency.ToString();

			if (payment.BillingAddress != null)
			{
				retVal.Addresses = new ObservableCollection<AddressEntity>(new AddressEntity[] { payment.BillingAddress.ToDataModel() });
			}
			return retVal;
		}
Exemplo n.º 3
0
        public virtual void Patch(PaymentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.Amount             = Amount;
            target.PaymentGatewayCode = PaymentGatewayCode;
            target.Price                 = Price;
            target.PriceWithTax          = PriceWithTax;
            target.DiscountAmount        = DiscountAmount;
            target.DiscountAmountWithTax = DiscountAmountWithTax;
            target.TaxType               = TaxType;
            target.TaxPercentRate        = TaxPercentRate;
            target.TaxTotal              = TaxTotal;
            target.Total                 = Total;
            target.TotalWithTax          = TotalWithTax;
            target.Purpose               = Purpose;
            target.Currency              = Currency;

            if (!Addresses.IsNullCollection())
            {
                Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance();

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance();

                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }