public virtual cartDto.ShoppingCart ToShoppingCartDto(ShoppingCart cart) { var result = new cartDto.ShoppingCart(); result.InjectFrom <NullableAndEnumValueInjecter>(cart); if (cart.Language != null) { result.LanguageCode = cart.Language.CultureName; } result.Addresses = cart.Addresses.Select(ToCartAddressDto).ToList(); result.Coupon = cart.Coupon != null ? new cartDto.Coupon { Code = cart.Coupon.Code, IsValid = cart.Coupon.AppliedSuccessfully } : null; result.Currency = cart.Currency.Code; result.Discounts = cart.Discounts.Select(ToCartDiscountDto).ToList(); result.HandlingTotal = (double)cart.HandlingTotal.Amount; result.HandlingTotalWithTax = (double)cart.HandlingTotal.Amount; result.DiscountAmount = (double)cart.DiscountAmount.Amount; result.Items = cart.Items.Select(ToLineItemDto).ToList(); result.Payments = cart.Payments.Select(ToPaymentDto).ToList(); result.Shipments = cart.Shipments.Select(ToShipmentDto).ToList(); result.TaxDetails = cart.TaxDetails.Select(ToCartTaxDetailDto).ToList(); result.DynamicProperties = cart.DynamicProperties.Select(ToCartDynamicPropertyDto).ToList(); result.VolumetricWeight = (double)cart.VolumetricWeight; result.Weight = (double)cart.Weight; return(result); }
public virtual ShoppingCart ToShoppingCart(cartDto.ShoppingCart cartDto, Currency currency, Language language, Model.Customer.CustomerInfo customer) { var result = new ShoppingCart(currency, language); result.InjectFrom <NullableAndEnumValueInjecter>(cartDto); result.Customer = customer; if (cartDto.Coupon != null) { result.Coupon = new Coupon { Code = cartDto.Coupon, AppliedSuccessfully = !string.IsNullOrEmpty(cartDto.Coupon) }; } if (cartDto.Items != null) { result.Items = cartDto.Items.Select(i => ToLineItem(i, currency, language)).ToList(); result.HasPhysicalProducts = result.Items.Any(i => string.IsNullOrEmpty(i.ProductType) || !string.IsNullOrEmpty(i.ProductType) && i.ProductType.Equals("Physical", StringComparison.OrdinalIgnoreCase)); } if (cartDto.Addresses != null) { result.Addresses = cartDto.Addresses.Select(ToAddress).ToList(); } if (cartDto.Payments != null) { result.Payments = cartDto.Payments.Select(p => ToPayment(p, result)).ToList(); } if (cartDto.Shipments != null) { result.Shipments = cartDto.Shipments.Select(s => ToShipment(s, result)).ToList(); } if (cartDto.DynamicProperties != null) { result.DynamicProperties = cartDto.DynamicProperties.Select(ToDynamicProperty).ToList(); } if (cartDto.TaxDetails != null) { result.TaxDetails = cartDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList(); } result.DiscountAmount = new Money(cartDto.DiscountAmount ?? 0, currency); result.HandlingTotal = new Money(cartDto.HandlingTotal ?? 0, currency); result.HandlingTotalWithTax = new Money(cartDto.HandlingTotalWithTax ?? 0, currency); result.IsAnonymous = cartDto.IsAnonymous == true; result.IsRecuring = cartDto.IsRecuring == true; result.VolumetricWeight = (decimal)(cartDto.VolumetricWeight ?? 0); result.Weight = (decimal)(cartDto.Weight ?? 0); return(result); }
public static cartDto.ShoppingCart ToShoppingCartDto(this ShoppingCart cart) { var result = new cartDto.ShoppingCart { ChannelId = cart.ChannelId, Comment = cart.Comment, CustomerId = cart.CustomerId, CustomerName = cart.CustomerName, Id = cart.Id, Name = cart.Name, OrganizationId = cart.OrganizationId, Status = cart.Status, StoreId = cart.StoreId, Type = cart.Type, IsAnonymous = cart.IsAnonymous, PurchaseOrderNumber = cart.PurchaseOrderNumber }; if (cart.Language != null) { result.LanguageCode = cart.Language.CultureName; } result.Addresses = cart.Addresses.Select(ToCartAddressDto).ToList(); result.Coupons = cart.Coupons?.Select(c => c.Code).ToList(); result.Currency = cart.Currency.Code; result.Discounts = cart.Discounts.Select(ToCartDiscountDto).ToList(); result.HandlingTotal = (double)cart.HandlingTotal.InternalAmount; result.HandlingTotalWithTax = (double)cart.HandlingTotal.InternalAmount; result.DiscountAmount = (double)cart.DiscountAmount.InternalAmount; result.Items = cart.Items.Select(ToLineItemDto).ToList(); result.Payments = cart.Payments.Select(ToPaymentDto).ToList(); result.Shipments = cart.Shipments.Select(ToShipmentDto).ToList(); result.TaxDetails = cart.TaxDetails.Select(ToCartTaxDetailDto).ToList(); result.DynamicProperties = cart.DynamicProperties.Select(ToCartDynamicPropertyDto).ToList(); result.VolumetricWeight = (double)cart.VolumetricWeight; result.Weight = (double)cart.Weight; result.ConfiguredGroups = cart.ConfiguredGroups.Select(x => x.ToConfiguredGroup()).ToList(); return(result); }
public virtual cartDto.ShoppingCart ToShoppingCartDto(ShoppingCart cart) { var result = new cartDto.ShoppingCart(); result.ChannelId = cart.ChannelId; result.Comment = cart.Comment; result.CustomerId = cart.CustomerId; result.CustomerName = cart.CustomerName; result.Id = cart.Id; result.Name = cart.Name; result.ObjectType = cart.ObjectType; result.OrganizationId = cart.OrganizationId; result.Status = cart.Status; result.StoreId = cart.StoreId; if (cart.Language != null) { result.LanguageCode = cart.Language.CultureName; } result.Addresses = cart.Addresses.Select(ToCartAddressDto).ToList(); result.Coupon = cart.Coupon != null ? cart.Coupon.Code : null; result.Currency = cart.Currency.Code; result.Discounts = cart.Discounts.Select(ToCartDiscountDto).ToList(); result.HandlingTotal = (double)cart.HandlingTotal.Amount; result.HandlingTotalWithTax = (double)cart.HandlingTotal.Amount; result.DiscountAmount = (double)cart.DiscountAmount.Amount; result.Items = cart.Items.Select(ToLineItemDto).ToList(); result.Payments = cart.Payments.Select(ToPaymentDto).ToList(); result.Shipments = cart.Shipments.Select(ToShipmentDto).ToList(); result.TaxDetails = cart.TaxDetails.Select(ToCartTaxDetailDto).ToList(); result.DynamicProperties = cart.DynamicProperties.Select(ToCartDynamicPropertyDto).ToList(); result.VolumetricWeight = (double)cart.VolumetricWeight; result.Weight = (double)cart.Weight; return(result); }
public virtual ShoppingCart ToShoppingCart(cartDto.ShoppingCart cartDto, Currency currency, Language language, Model.Customer.CustomerInfo customer) { var result = ServiceLocator.Current.GetInstance <CartFactory>().CreateCart(currency, language); result.InjectFrom <NullableAndEnumValueInjecter>(cartDto); result.Customer = customer; if (cartDto.Coupon != null) { result.Coupon = new Coupon { Code = cartDto.Coupon.Code, AppliedSuccessfully = cartDto.Coupon.IsValid ?? false }; } if (cartDto.Items != null) { result.Items = cartDto.Items.Select(i => ToLineItem(i, currency, language)).ToList(); result.HasPhysicalProducts = result.Items.Any(i => string.IsNullOrEmpty(i.ProductType) || !string.IsNullOrEmpty(i.ProductType) && i.ProductType.Equals("Physical", StringComparison.OrdinalIgnoreCase)); } if (cartDto.Addresses != null) { result.Addresses = cartDto.Addresses.Select(ToAddress).ToList(); var billingAddress = result.Addresses.FirstOrDefault(a => a.Type == AddressType.Billing); if (billingAddress == null) { billingAddress = new Address { Type = AddressType.Billing }; } if (result.HasPhysicalProducts) { var shippingAddress = result.Addresses.FirstOrDefault(a => a.Type == AddressType.Shipping); if (shippingAddress == null) { shippingAddress = new Address { Type = AddressType.Shipping }; } } } if (cartDto.Payments != null) { result.Payments = cartDto.Payments.Select(p => ToPayment(p, currency)).ToList(); } if (cartDto.Shipments != null) { result.Shipments = cartDto.Shipments.Select(s => ToShipment(s, result)).ToList(); } if (cartDto.DynamicProperties != null) { result.DynamicProperties = cartDto.DynamicProperties.Select(ToDynamicProperty).ToList(); } if (cartDto.TaxDetails != null) { result.TaxDetails = cartDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList(); } result.DiscountAmount = new Money(cartDto.DiscountAmount ?? 0, currency); result.HandlingTotal = new Money(cartDto.HandlingTotal ?? 0, currency); result.HandlingTotalWithTax = new Money(cartDto.HandlingTotalWithTax ?? 0, currency); result.IsAnonymous = cartDto.IsAnonymous == true; result.IsRecuring = cartDto.IsRecuring == true; result.VolumetricWeight = (decimal)(cartDto.VolumetricWeight ?? 0); result.Weight = (decimal)(cartDto.Weight ?? 0); return(result); }
public static ShoppingCart ToShoppingCart(this cartDto.ShoppingCart cartDto, Currency currency, Language language, Model.Customer.CustomerInfo customer) { return(CartConverterInstance.ToShoppingCart(cartDto, currency, language, customer)); }
public static ShoppingCart ToShoppingCart(this cartDto.ShoppingCart cartDto, Currency currency, Language language, User user) { var result = new ShoppingCart(currency, language) { ChannelId = cartDto.ChannelId, Comment = cartDto.Comment, CustomerId = cartDto.CustomerId, CustomerName = cartDto.CustomerName, Id = cartDto.Id, Name = cartDto.Name, ObjectType = cartDto.ObjectType, OrganizationId = cartDto.OrganizationId, Status = cartDto.Status, StoreId = cartDto.StoreId, Type = cartDto.Type, Customer = user, PurchaseOrderNumber = cartDto.PurchaseOrderNumber }; if (cartDto.Coupons != null) { result.Coupons = cartDto.Coupons.Select(c => new Coupon { Code = c, AppliedSuccessfully = !string.IsNullOrEmpty(c) }).ToList(); } if (cartDto.Items != null) { result.Items = cartDto.Items.Select(i => ToLineItem(i, currency, language)).ToList(); result.HasPhysicalProducts = result.Items.Any(i => string.IsNullOrEmpty(i.ProductType) || !string.IsNullOrEmpty(i.ProductType) && i.ProductType.Equals("Physical", StringComparison.OrdinalIgnoreCase)); } if (cartDto.Addresses != null) { result.Addresses = cartDto.Addresses.Select(ToAddress).ToList(); } if (cartDto.Payments != null) { result.Payments = cartDto.Payments.Select(p => ToPayment(p, result)).ToList(); } if (cartDto.Shipments != null) { result.Shipments = cartDto.Shipments.Select(s => ToShipment(s, result)).ToList(); } if (cartDto.DynamicProperties != null) { result.DynamicProperties = cartDto.DynamicProperties.Select(ToDynamicProperty).ToList(); } if (cartDto.TaxDetails != null) { result.TaxDetails = cartDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList(); } result.DiscountAmount = new Money(cartDto.DiscountAmount ?? 0, currency); result.HandlingTotal = new Money(cartDto.HandlingTotal ?? 0, currency); result.HandlingTotalWithTax = new Money(cartDto.HandlingTotalWithTax ?? 0, currency); result.Total = new Money(cartDto.Total ?? 0, currency); result.SubTotal = new Money(cartDto.SubTotal ?? 0, currency); result.SubTotalWithTax = new Money(cartDto.SubTotalWithTax ?? 0, currency); result.ShippingPrice = new Money(cartDto.ShippingSubTotal ?? 0, currency); result.ShippingPriceWithTax = new Money(cartDto.ShippingSubTotalWithTax ?? 0, currency); result.ShippingTotal = new Money(cartDto.ShippingTotal ?? 0, currency); result.ShippingTotalWithTax = new Money(cartDto.ShippingTotalWithTax ?? 0, currency); result.PaymentPrice = new Money(cartDto.PaymentSubTotal ?? 0, currency); result.PaymentPriceWithTax = new Money(cartDto.PaymentSubTotalWithTax ?? 0, currency); result.PaymentTotal = new Money(cartDto.PaymentTotal ?? 0, currency); result.PaymentTotalWithTax = new Money(cartDto.PaymentTotalWithTax ?? 0, currency); result.DiscountTotal = new Money(cartDto.DiscountTotal ?? 0, currency); result.DiscountTotalWithTax = new Money(cartDto.DiscountTotalWithTax ?? 0, currency); result.TaxTotal = new Money(cartDto.TaxTotal ?? 0, currency); result.IsAnonymous = cartDto.IsAnonymous == true; result.IsRecuring = cartDto.IsRecuring == true; result.VolumetricWeight = (decimal)(cartDto.VolumetricWeight ?? 0); result.Weight = (decimal)(cartDto.Weight ?? 0); if (!cartDto.ConfiguredGroups.IsNullOrEmpty()) { result.ConfiguredGroups = cartDto.ConfiguredGroups.Select(x => x.ToConfiguredGroup(result)).ToList(); } return(result); }
public static ShoppingCart ToShoppingCart(this cartDto.ShoppingCart cartDto, Currency currency, Language language, User user) { return(CartConverterInstance.ToShoppingCart(cartDto, currency, language, user)); }