/// <summary> /// Patch CatalogBase type /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this LineItemEntity source, LineItemEntity target) { if (target == null) { throw new ArgumentNullException("target"); } var patchInjectionPolicy = new PatchInjection <LineItemEntity>(x => x.BasePrice, x => x.Price, x => x.Quantity, x => x.DiscountAmount, x => x.Tax, x => x.Height, x => x.Length, x => x.Width, x => x.MeasureUnit, x => x.WeightUnit, x => x.Weight, x => x.TaxType, x => x.IsCancelled, x => x.CancelledDate, x => x.CancelReason); target.InjectFrom(patchInjectionPolicy, source); if (!source.Discounts.IsNullCollection()) { source.Discounts.Patch(target.Discounts, new DiscountComparer(), (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount)); } if (!source.TaxDetails.IsNullCollection()) { var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name); source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail)); } }
public static LineItemEntity ToDataModel(this LineItem lineItem, PrimaryKeyResolvingMap pkMap) { if (lineItem == null) { throw new ArgumentNullException("lineItem"); } var retVal = new LineItemEntity(); pkMap.AddPair(lineItem, retVal); retVal.InjectFrom(lineItem); retVal.Currency = lineItem.Currency.ToString(); if (lineItem.TaxDetails != null) { retVal.TaxDetails = new ObservableCollection <TaxDetailEntity>(); retVal.TaxDetails.AddRange(lineItem.TaxDetails.Select(x => x.ToDataModel())); } if (lineItem.Discounts != null) { retVal.Discounts = new ObservableCollection <DiscountEntity>(); retVal.Discounts.AddRange(lineItem.Discounts.Select(x => x.ToDataModel(pkMap))); } return(retVal); }
public override void Patch(LineItemEntity target) { base.Patch(target); var lineItem2 = target as LineItem2Entity; lineItem2.OuterId = this.OuterId; }
public override void Patch(LineItemEntity target) { base.Patch(target); var orderLineItemExtensionEntity = target as OrderLineItemExtensionEntity; orderLineItemExtensionEntity.ProductConfigurationRequestId = this.ProductConfigurationRequestId; }
public override void Patch(LineItemEntity target) { base.Patch(target); var lineItem2Entity = (LineItemExEntity)target; lineItem2Entity.OuterId = OuterId; }
public override void Patch(LineItemEntity target) { base.Patch(target); if (target is DemoCartLineItemEntity demoCartLineItem) { demoCartLineItem.ConfiguredGroupId = ConfiguredGroupId; } }
public static LineItem ToCoreModel(this LineItemEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } var retVal = new LineItem(); retVal.InjectFrom(entity); retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency); retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList(); return(retVal); }
/// <summary> /// Patch CatalogBase type /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this LineItemEntity source, LineItemEntity target) { if (target == null) { throw new ArgumentNullException("target"); } var patchInjection = new PatchInjection <LineItemEntity>(x => x.Quantity, x => x.SalePrice, x => x.PlacedPrice, x => x.ListPrice, x => x.TaxIncluded, x => x.TaxTotal); target.InjectFrom(patchInjection, source); if (!source.TaxDetails.IsNullCollection()) { var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name); source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail)); } }
public static LineItemEntity ToDataModel(this LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException("lineItem"); } var retVal = new LineItemEntity(); retVal.InjectFrom(lineItem); retVal.Currency = lineItem.Currency.ToString(); if (lineItem.TaxDetails != null) { retVal.TaxDetails = new ObservableCollection <TaxDetailEntity>(); retVal.TaxDetails.AddRange(lineItem.TaxDetails.Select(x => x.ToDataModel())); } return(retVal); }
public static LineItem ToCoreModel(this LineItemEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } var retVal = new LineItem(); retVal.InjectFrom(entity); retVal.Currency = entity.Currency; if (entity.Discounts != null && entity.Discounts.Any()) { retVal.Discount = entity.Discounts.First().ToCoreModel(); } retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList(); return(retVal); }
public static CustomerOrderEntity GetResetedOrder() { var orderId = "orderId"; var order = new CustomerOrderEntity { Id = orderId, CustomerId = "customerId", StoreId = "storeId", Number = "number", Currency = "usd", PaymentTotal = 1, PaymentTotalWithTax = 1, ShippingTotalWithTax = 1, DiscountAmount = 1, DiscountTotal = 1, DiscountTotalWithTax = 1, HandlingTotal = 1, HandlingTotalWithTax = 1, ShippingTotal = 1, SubTotal = 1, SubTotalWithTax = 1, Sum = 1, TaxPercentRate = 1, TaxTotal = 1, Total = 1 }; var item = new LineItemEntity { CustomerOrderId = orderId, Id = "itemId", Currency = "usd", ProductId = "productId", CatalogId = "catalogId", Sku = "sku", Name = "itemName", Price = 1, DiscountAmount = 1, TaxPercentRate = 1, TaxTotal = 1, DiscountAmountWithTax = 1, PriceWithTax = 1, }; var payment = new PaymentInEntity { CustomerOrderId = orderId, Id = "paymentId", CustomerId = "customerId", Number = "number", Currency = "usd", Price = 1, DiscountAmount = 1, DiscountAmountWithTax = 1, PriceWithTax = 1, TaxPercentRate = 1, TaxTotal = 1, Total = 1, Sum = 1, TotalWithTax = 1, }; var shipment = new ShipmentEntity { CustomerOrderId = orderId, Id = "shipmentId", Number = "number", Currency = "usd", Price = 1, DiscountAmount = 1, DiscountAmountWithTax = 1, PriceWithTax = 1, Sum = 1, TaxPercentRate = 1, TaxTotal = 1, Total = 1, TotalWithTax = 1, }; order.ResetPrices(); item.ResetPrices(); payment.ResetPrices(); shipment.ResetPrices(); order.Items = new ObservableCollection <LineItemEntity> { item }; order.InPayments = new ObservableCollection <PaymentInEntity> { payment }; order.Shipments = new ObservableCollection <ShipmentEntity> { shipment }; return(order); }
public static decimal CalculateTotal(this LineItemEntity li) { return(li.Quantity * li.Price); }