public override object Clone() { var result = base.Clone() as Shipment; result.Price = Price?.Clone() as Money; result.PriceWithTax = PriceWithTax?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money; result.Total = Total?.Clone() as Money; result.TotalWithTax = TotalWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (Items != null) { result.Items = new List <CartShipmentItem>(Items.Select(x => x.Clone() as CartShipmentItem)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } return(result); }
public virtual Payment ToModel(Payment payment) { if (payment == null) { throw new ArgumentNullException(nameof(payment)); } payment.InjectFrom(this); if (!TaxDetails.IsNullOrEmpty()) { payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } if (!Discounts.IsNullOrEmpty()) { payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Addresses.IsNullOrEmpty()) { payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } return(payment); }
public override object Clone() { var result = base.Clone() as Payment; result.Currency = result.Currency?.Clone() as Currency; result.Price = result.Price?.Clone() as Money; result.PriceWithTax = result.PriceWithTax?.Clone() as Money; result.DiscountAmount = result.DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = result.DiscountAmountWithTax?.Clone() as Money; result.Amount = result.Amount?.Clone() as Money; result.Total = result.Total?.Clone() as Money; result.TotalWithTax = result.TotalWithTax?.Clone() as Money; result.TaxTotal = result.TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } return(result); }
public virtual LineItem ToModel(LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException(nameof(lineItem)); } lineItem.Id = Id; lineItem.CreatedDate = CreatedDate; lineItem.CreatedBy = CreatedBy; lineItem.ModifiedDate = ModifiedDate; lineItem.ModifiedBy = ModifiedBy; lineItem.OuterId = OuterId; lineItem.PriceId = PriceId; lineItem.CatalogId = CatalogId; lineItem.CategoryId = CategoryId; lineItem.Currency = Currency; lineItem.ProductId = ProductId; lineItem.Sku = Sku; lineItem.ProductType = ProductType; lineItem.Name = Name; lineItem.ImageUrl = ImageUrl; lineItem.ShippingMethodCode = ShippingMethodCode; lineItem.FulfillmentLocationCode = FulfillmentLocationCode; lineItem.Price = Price; lineItem.PriceWithTax = PriceWithTax; lineItem.DiscountAmount = DiscountAmount; lineItem.DiscountAmountWithTax = DiscountAmountWithTax; lineItem.Quantity = Quantity; lineItem.TaxTotal = TaxTotal; lineItem.TaxPercentRate = TaxPercentRate; lineItem.Weight = Weight; lineItem.Height = Height; lineItem.Width = Width; lineItem.MeasureUnit = MeasureUnit; lineItem.WeightUnit = WeightUnit; lineItem.Length = Length; lineItem.TaxType = TaxType; lineItem.IsCancelled = IsCancelled; lineItem.CancelledDate = CancelledDate; lineItem.CancelReason = CancelReason; lineItem.Comment = Comment; lineItem.IsGift = IsGift; lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); lineItem.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); return(lineItem); }
public override OrderOperation ToModel(OrderOperation operation) { var order = operation as CustomerOrder; if (order == null) { throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation)); } order.CustomerId = CustomerId; order.CustomerName = CustomerName; order.StoreId = StoreId; order.StoreName = StoreName; order.OrganizationId = OrganizationId; order.OrganizationName = OrganizationName; order.EmployeeId = EmployeeId; order.EmployeeName = EmployeeName; order.DiscountAmount = DiscountAmount; order.Total = Total; order.SubTotal = SubTotal; order.SubTotalWithTax = SubTotalWithTax; order.ShippingTotal = ShippingTotal; order.ShippingTotalWithTax = ShippingTotalWithTax; order.PaymentTotal = PaymentTotal; order.PaymentTotalWithTax = PaymentTotalWithTax; order.FeeTotal = HandlingTotal; order.FeeTotalWithTax = HandlingTotalWithTax; order.DiscountTotal = DiscountTotal; order.DiscountTotalWithTax = DiscountTotalWithTax; order.DiscountAmount = DiscountAmount; order.TaxTotal = TaxTotal; order.IsPrototype = IsPrototype; order.SubscriptionNumber = SubscriptionNumber; order.SubscriptionId = SubscriptionId; order.LanguageCode = LanguageCode; order.TaxPercentRate = TaxPercentRate; order.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); order.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList(); order.Addresses = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList(); order.Shipments = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).OfType <Shipment>().ToList(); order.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList(); order.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); order.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); base.ToModel(order); Sum = order.Total; return(order); }
public virtual LineItem ToModel(LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException(nameof(lineItem)); } lineItem.Id = Id; lineItem.CreatedBy = CreatedBy; lineItem.CreatedDate = CreatedDate; lineItem.ModifiedBy = ModifiedBy; lineItem.ModifiedDate = ModifiedDate; lineItem.ListPrice = ListPrice; lineItem.ListPriceWithTax = ListPriceWithTax; lineItem.SalePrice = SalePrice; lineItem.SalePriceWithTax = SalePriceWithTax; lineItem.Fee = Fee; lineItem.FeeWithTax = FeeWithTax; lineItem.DiscountAmount = DiscountAmount; lineItem.DiscountAmountWithTax = DiscountAmountWithTax; lineItem.Quantity = Quantity; lineItem.TaxTotal = TaxTotal; lineItem.TaxPercentRate = TaxPercentRate; lineItem.Weight = Weight; lineItem.Height = Height; lineItem.Width = Width; lineItem.MeasureUnit = MeasureUnit; lineItem.WeightUnit = WeightUnit; lineItem.Length = Length; lineItem.TaxType = TaxType; lineItem.IsReadOnly = IsReadOnly; lineItem.ValidationType = ValidationType; lineItem.PriceId = PriceId; lineItem.LanguageCode = LanguageCode; lineItem.IsReccuring = IsReccuring; lineItem.IsGift = IsGift; lineItem.ImageUrl = ImageUrl; lineItem.ProductId = ProductId; lineItem.ProductType = ProductType; lineItem.ShipmentMethodCode = ShipmentMethodCode; lineItem.RequiredShipping = RequiredShipping; lineItem.ProductType = ProductType; lineItem.FulfillmentLocationCode = FulfillmentLocationCode; lineItem.Note = Comment; if (!Discounts.IsNullOrEmpty()) { lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!TaxDetails.IsNullOrEmpty()) { lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } return(lineItem); }
public virtual object Clone() { var result = MemberwiseClone() as PaymentMethod; result.Settings = Settings?.Select(x => x.Clone()).OfType <ObjectSettingEntry>().ToList(); result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); return(result); }
public virtual ShoppingCart ToModel(ShoppingCart cart) { if (cart == null) { throw new ArgumentNullException(nameof(cart)); } cart.Id = Id; cart.CreatedBy = CreatedBy; cart.CreatedDate = CreatedDate; cart.ModifiedBy = ModifiedBy; cart.ModifiedDate = ModifiedDate; cart.StoreId = StoreId; cart.Fee = Fee; cart.FeeWithTax = FeeWithTax; cart.Status = Status; cart.Currency = Currency; cart.ValidationType = ValidationType; cart.CustomerId = CustomerId; cart.CustomerName = CustomerName; cart.IsAnonymous = IsAnonymous; cart.IsRecuring = IsRecuring; cart.LanguageCode = LanguageCode; cart.Comment = Comment; cart.OrganizationId = OrganizationId; cart.Total = Total; cart.SubTotal = SubTotal; cart.SubTotalWithTax = SubTotalWithTax; cart.ShippingTotal = ShippingTotal; cart.ShippingTotalWithTax = ShippingTotalWithTax; cart.PaymentTotal = PaymentTotal; cart.PaymentTotalWithTax = PaymentTotalWithTax; cart.HandlingTotal = HandlingTotal; cart.HandlingTotalWithTax = HandlingTotalWithTax; cart.DiscountTotal = DiscountTotal; cart.DiscountTotalWithTax = DiscountTotalWithTax; cart.DiscountAmount = DiscountAmount; cart.TaxTotal = TaxTotal; cart.TaxPercentRate = TaxPercentRate; cart.Type = Type; cart.Name = Name; cart.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); cart.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList(); cart.Addresses = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList(); cart.Shipments = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).ToList(); cart.Payments = Payments.Select(x => x.ToModel(AbstractTypeFactory <Payment> .TryCreateInstance())).ToList(); cart.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); cart.Coupons = Coupons.Select(x => x.Code).ToList(); // Assigning single coupon to preserve backwards compatibility with previous versions of CartModule cart.Coupon = cart.Coupons.FirstOrDefault(); return(cart); }
public virtual Payment ToModel(Payment payment) { if (payment == null) { throw new ArgumentNullException(nameof(payment)); } payment.Id = Id; payment.OuterId = OuterId; payment.CreatedBy = CreatedBy; payment.CreatedDate = CreatedDate; payment.ModifiedBy = ModifiedBy; payment.ModifiedDate = ModifiedDate; payment.Amount = Amount; payment.PaymentGatewayCode = PaymentGatewayCode; payment.Price = Price; payment.PriceWithTax = PriceWithTax; payment.DiscountAmount = DiscountAmount; payment.DiscountAmountWithTax = DiscountAmountWithTax; payment.TaxType = TaxType; payment.TaxPercentRate = TaxPercentRate; payment.TaxTotal = TaxTotal; payment.Total = Total; payment.TotalWithTax = TotalWithTax; //TODO //payment.Purpose = Purpose; payment.Currency = Currency; if (!TaxDetails.IsNullOrEmpty()) { payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } if (!Discounts.IsNullOrEmpty()) { payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Addresses.IsNullOrEmpty()) { payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } payment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); return(payment); }
public virtual object Clone() { var result = MemberwiseClone() as LineItem; result.Price = Price?.Clone() as Price; result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList(); return(result); }
public object Clone() { var result = MemberwiseClone() as Payment; result.BillingAddress = BillingAddress?.Clone() as Address; result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList(); return(result); }
public virtual object Clone() { var result = MemberwiseClone() as Shipment; result.DeliveryAddress = DeliveryAddress?.Clone() as Address; result.Items = Items?.Select(x => x.Clone()).OfType <ShipmentItem>().ToList(); result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList(); return(result); }
public virtual LineItem ToModel(LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException(nameof(lineItem)); } lineItem.InjectFrom(this); lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); return(lineItem); }
public override object Clone() { var result = base.Clone() as CustomerOrder; result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); result.Addresses = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList(); result.InPayments = InPayments?.Select(x => x.Clone()).OfType <PaymentIn>().ToList(); result.Items = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList(); result.Shipments = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList(); result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); return(result); }
public override object Clone() { var result = base.Clone() as PaymentIn; result.PaymentMethod = PaymentMethod?.Clone() as PaymentMethod; result.BillingAddress = BillingAddress?.Clone() as Address; result.ProcessPaymentResult = ProcessPaymentResult?.Clone() as ProcessPaymentRequestResult; result.Transactions = Transactions?.Select(x => x.Clone()).OfType <PaymentGatewayTransaction>().ToList(); result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); return(result); }
public virtual object Clone() { var result = MemberwiseClone() as ShoppingCart; result.Discounts = Discounts?.Select(x => x.Clone()).OfType <Discount>().ToList(); result.Addresses = Addresses?.Select(x => x.Clone()).OfType <Address>().ToList(); result.Items = Items?.Select(x => x.Clone()).OfType <LineItem>().ToList(); result.Payments = Payments?.Select(x => x.Clone()).OfType <Payment>().ToList(); result.Shipments = Shipments?.Select(x => x.Clone()).OfType <Shipment>().ToList(); result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType <TaxDetail>().ToList(); result.DynamicProperties = DynamicProperties?.Select(x => x.Clone()).OfType <DynamicObjectProperty>().ToList(); return(result); }
public virtual LineItem ToModel(LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException(nameof(lineItem)); } lineItem.Id = Id; lineItem.CreatedDate = CreatedDate; lineItem.CreatedBy = CreatedBy; lineItem.ModifiedDate = ModifiedDate; lineItem.ModifiedBy = ModifiedBy; lineItem.PriceId = PriceId; lineItem.CatalogId = CatalogId; lineItem.CategoryId = CategoryId; lineItem.Currency = Currency; lineItem.ProductId = ProductId; lineItem.Sku = Sku; lineItem.ProductType = ProductType; lineItem.Name = Name; lineItem.ImageUrl = ImageUrl; lineItem.ShippingMethodCode = ShippingMethodCode; lineItem.FulfillmentLocationCode = FulfillmentLocationCode; lineItem.Price = Price; lineItem.PriceWithTax = PriceWithTax; lineItem.DiscountAmount = DiscountAmount; lineItem.DiscountAmountWithTax = DiscountAmountWithTax; lineItem.Quantity = Quantity; lineItem.TaxTotal = TaxTotal; lineItem.TaxPercentRate = TaxPercentRate; lineItem.Weight = Weight; lineItem.Height = Height; lineItem.Width = Width; lineItem.MeasureUnit = MeasureUnit; lineItem.WeightUnit = WeightUnit; lineItem.Length = Length; lineItem.TaxType = TaxType; lineItem.IsCancelled = IsCancelled; lineItem.CancelledDate = CancelledDate; lineItem.CancelReason = CancelReason; lineItem.Comment = Comment; lineItem.IsGift = IsGift; lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); return(lineItem); }
public override object Clone() { var result = base.Clone() as PaymentMethod; result.Price = Price?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } return(result); }
public virtual Payment ToModel(Payment payment) { if (payment == null) { throw new ArgumentNullException(nameof(payment)); } payment.Id = Id; payment.CreatedBy = CreatedBy; payment.CreatedDate = CreatedDate; payment.ModifiedBy = ModifiedBy; payment.ModifiedDate = ModifiedDate; payment.Amount = Amount; payment.PaymentGatewayCode = PaymentGatewayCode; payment.Price = Price; payment.PriceWithTax = PriceWithTax; payment.DiscountAmount = DiscountAmount; payment.DiscountAmountWithTax = DiscountAmountWithTax; payment.TaxType = TaxType; payment.TaxPercentRate = TaxPercentRate; payment.TaxTotal = TaxTotal; payment.Total = Total; payment.TotalWithTax = TotalWithTax; //TODO //payment.Purpose = Purpose; payment.OuterId = OuterId; payment.Currency = Currency; if (!TaxDetails.IsNullOrEmpty()) { payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } if (!Discounts.IsNullOrEmpty()) { payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Addresses.IsNullOrEmpty()) { payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } return(payment); }
public virtual ShoppingCart ToModel(ShoppingCart cart) { if (cart == null) { throw new ArgumentNullException(nameof(cart)); } cart.InjectFrom(this); cart.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); cart.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList(); cart.Addresses = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList(); cart.Shipments = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).ToList(); cart.Payments = Payments.Select(x => x.ToModel(AbstractTypeFactory <Payment> .TryCreateInstance())).ToList(); cart.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); cart.Coupons = Coupons.Select(x => x.Code).ToList(); //back compatibility changes cart.Coupon = cart.Coupons.FirstOrDefault(); return(cart); }
public override OrderOperation ToModel(OrderOperation operation) { var order = operation as CustomerOrder; if (order == null) { throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation)); } order.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); order.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList(); order.Addresses = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList(); order.Shipments = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).OfType <Shipment>().ToList(); order.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList(); order.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); base.ToModel(order); Sum = order.Total; return(order); }
public override object Clone() { var result = base.Clone() as LineItem; result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money; result.DiscountTotal = DiscountTotal?.Clone() as Money; result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money; result.ListPriceWithTax = ListPriceWithTax?.Clone() as Money; result.SalePriceWithTax = SalePriceWithTax?.Clone() as Money; result.PlacedPrice = PlacedPrice?.Clone() as Money; result.PlacedPriceWithTax = PlacedPriceWithTax?.Clone() as Money; result.ExtendedPrice = ExtendedPrice?.Clone() as Money; result.ExtendedPriceWithTax = ExtendedPriceWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (DynamicProperties != null) { result.DynamicProperties = new MutablePagedList <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } return(result); }
public override OrderOperation ToModel(OrderOperation operation) { var payment = operation as PaymentIn; if (payment == null) { throw new ArgumentException(@"operation argument must be of type PaymentIn", nameof(operation)); } if (!Addresses.IsNullOrEmpty()) { payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } payment.OrderId = CustomerOrderId; payment.Price = Price; payment.PriceWithTax = PriceWithTax; payment.DiscountAmount = DiscountAmount; payment.DiscountAmountWithTax = DiscountAmountWithTax; payment.TaxType = TaxType; payment.TaxPercentRate = TaxPercentRate; payment.TaxTotal = TaxTotal; payment.Total = Total; payment.TotalWithTax = TotalWithTax; payment.CustomerId = CustomerId; payment.CustomerName = CustomerName; payment.OrganizationId = OrganizationId; payment.OrganizationName = OrganizationName; payment.GatewayCode = GatewayCode; payment.Purpose = Purpose; payment.OuterId = OuterId; payment.Status = Status; payment.AuthorizedDate = AuthorizedDate; payment.CapturedDate = CapturedDate; payment.VoidedDate = VoidedDate; payment.IsCancelled = IsCancelled; payment.CancelledDate = CancelledDate; payment.CancelReason = CancelReason; payment.Sum = Sum; payment.Transactions = Transactions.Select(x => x.ToModel(AbstractTypeFactory <PaymentGatewayTransaction> .TryCreateInstance())).ToList(); payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); payment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); base.ToModel(payment); payment.PaymentStatus = EnumUtility.SafeParse(Status, PaymentStatus.Custom); return(payment); }
public virtual Shipment ToModel(Shipment shipment) { if (shipment == null) { throw new ArgumentNullException(nameof(shipment)); } shipment.Id = Id; shipment.CreatedBy = CreatedBy; shipment.CreatedDate = CreatedDate; shipment.ModifiedBy = ModifiedBy; shipment.ModifiedDate = ModifiedDate; shipment.Fee = Fee; shipment.FeeWithTax = FeeWithTax; shipment.FulfillmentCenterId = FulfillmentCenterId; shipment.ShipmentMethodCode = ShipmentMethodCode; shipment.Total = Total; shipment.TotalWithTax = TotalWithTax; shipment.TaxTotal = TaxTotal; shipment.Price = Price; shipment.PriceWithTax = PriceWithTax; shipment.DiscountAmount = DiscountAmount; shipment.DiscountAmountWithTax = DiscountAmountWithTax; shipment.TaxPercentRate = TaxPercentRate; shipment.Currency = Currency; shipment.WeightUnit = WeightUnit; shipment.Weight = WeightValue; shipment.Height = DimensionHeight; shipment.Length = DimensionLength; shipment.WeightUnit = DimensionUnit; shipment.Weight = DimensionWidth; shipment.TaxType = TaxType; shipment.ShipmentMethodOption = ShipmentMethodOption; //TODO //shipment.TaxIncluded = TaxIncluded; //shipment.MeasureUnit = if (!Addresses.IsNullOrEmpty()) { shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } if (!Discounts.IsNullOrEmpty()) { shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Items.IsNullOrEmpty()) { shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList(); } if (!TaxDetails.IsNullOrEmpty()) { shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } shipment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); return(shipment); }
public override OrderOperation ToModel(OrderOperation operation) { var shipment = operation as Shipment; if (shipment == null) { throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation)); } if (!Addresses.IsNullOrEmpty()) { shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } shipment.Id = Id; shipment.CreatedDate = CreatedDate; shipment.CreatedBy = CreatedBy; shipment.ModifiedDate = ModifiedDate; shipment.ModifiedBy = ModifiedBy; shipment.OuterId = OuterId; shipment.Price = Price; shipment.PriceWithTax = PriceWithTax; shipment.DiscountAmount = DiscountAmount; shipment.DiscountAmountWithTax = DiscountAmountWithTax; shipment.FulfillmentCenterId = FulfillmentCenterId; shipment.FulfillmentCenterName = FulfillmentCenterName; shipment.OrganizationId = OrganizationId; shipment.OrganizationName = OrganizationName; shipment.EmployeeId = EmployeeId; shipment.EmployeeName = EmployeeName; shipment.ShipmentMethodCode = ShipmentMethodCode; shipment.ShipmentMethodOption = ShipmentMethodOption; shipment.Height = Height; shipment.Length = Length; shipment.Weight = Weight; shipment.Height = Height; shipment.Width = Width; shipment.MeasureUnit = MeasureUnit; shipment.WeightUnit = WeightUnit; shipment.Length = Length; shipment.TaxType = TaxType; shipment.TaxPercentRate = TaxPercentRate; shipment.TaxTotal = TaxTotal; shipment.Total = Total; shipment.TotalWithTax = TotalWithTax; shipment.CustomerOrderId = CustomerOrderId; shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList(); shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList(); shipment.Packages = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList(); shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); shipment.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); base.ToModel(shipment); operation.Sum = shipment.TotalWithTax; return(shipment); }
public override object Clone() { var result = base.Clone() as ShoppingCart; result.HandlingTotal = HandlingTotal?.Clone() as Money; result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.Total = Total?.Clone() as Money; result.SubTotal = SubTotal?.Clone() as Money; result.SubTotalWithTax = SubTotalWithTax?.Clone() as Money; result.ShippingPrice = ShippingPrice?.Clone() as Money; result.ShippingPriceWithTax = ShippingPriceWithTax?.Clone() as Money; result.ShippingTotal = ShippingTotal?.Clone() as Money; result.ShippingTotalWithTax = ShippingTotalWithTax?.Clone() as Money; result.PaymentPrice = PaymentPrice?.Clone() as Money; result.PaymentPriceWithTax = PaymentPriceWithTax?.Clone() as Money; result.PaymentTotal = PaymentTotal?.Clone() as Money; result.PaymentTotalWithTax = PaymentTotalWithTax?.Clone() as Money; result.HandlingTotal = HandlingTotal?.Clone() as Money; result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money; result.DiscountTotal = DiscountTotal?.Clone() as Money; result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (DynamicProperties != null) { result.DynamicProperties = new List <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } if (Addresses != null) { result.Addresses = new List <Address>(Addresses.Select(x => x.Clone() as Address)); } if (Items != null) { result.Items = new List <LineItem>(Items.Select(x => x.Clone() as LineItem)); } if (Payments != null) { result.Payments = new List <Payment>(Payments.Select(x => x.Clone() as Payment)); } if (Shipments != null) { result.Shipments = new List <Shipment>(Shipments.Select(x => x.Clone() as Shipment)); } if (Coupons != null) { result.Coupons = new List <Coupon>(Coupons.Select(x => x.Clone() as Coupon)); } if (AvailablePaymentMethods != null) { result.AvailablePaymentMethods = new List <PaymentMethod>(AvailablePaymentMethods.Select(x => x.Clone() as PaymentMethod)); } return(result); }