public virtual ShippingMethod ToShippingMethod(cartDto.ShippingRate shippingRate, Currency currency, IEnumerable <Currency> availCurrencies) { var rateCurrency = availCurrencies.FirstOrDefault(x => x.Equals(shippingRate.Currency)) ?? new Currency(new Language(currency.CultureName), shippingRate.Currency); var ratePrice = new Money(shippingRate.Rate ?? 0, rateCurrency); var rateDiscount = new Money(shippingRate.DiscountAmount ?? 0, rateCurrency); if (rateCurrency != currency) { ratePrice = ratePrice.ConvertTo(currency); rateDiscount = rateDiscount.ConvertTo(currency); } var result = new ShippingMethod(currency); result.InjectFrom <NullableAndEnumValueInjecter>(shippingRate); result.Price = ratePrice; result.DiscountAmount = rateDiscount; if (shippingRate.ShippingMethod != null) { result.InjectFrom <NullableAndEnumValueInjecter>(shippingRate.ShippingMethod); result.ShipmentMethodCode = shippingRate.ShippingMethod.Code; if (shippingRate.ShippingMethod.Settings != null) { result.Settings = shippingRate.ShippingMethod.Settings.Where(x => !x.ValueType.EqualsInvariant("SecureString")) .Select(x => x.JsonConvert <platformDto.Setting>().ToSettingEntry()).ToList(); } } return(result); }
public static ShippingMethod ToWebModel(this QuoteModule.Client.Model.ShipmentMethod serviceModel, Currency currency) { var webModel = new ShippingMethod(); webModel.InjectFrom <NullableAndEnumValueInjecter>(serviceModel); webModel.Price = new Money(serviceModel.Price ?? 0, currency); return(webModel); }
public virtual ShippingMethod ToShippingMethod(quoteDto.ShipmentMethod shippingMethodDto, Currency currency) { var result = new ShippingMethod(currency); result.InjectFrom <NullableAndEnumValueInjecter>(shippingMethodDto); result.Price = new Money(shippingMethodDto.Price ?? 0, currency); return(result); }
public static ShippingMethod ToWebModel(this CartModule.Client.Model.ShippingMethod shippingMethod, Currency currency) { var shippingMethodModel = new ShippingMethod(currency); shippingMethodModel.InjectFrom(shippingMethod); shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency); return(shippingMethodModel); }
public static ShippingMethod ToWebModel(this VirtoCommerceQuoteModuleWebModelShipmentMethod serviceModel, Currency currency) { var webModel = new ShippingMethod(); webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel); webModel.Price = new Money(serviceModel.Price ?? 0, currency); return webModel; }
public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod, IEnumerable<Currency> availCurrencies, Language language) { var shippingMethodModel = new ShippingMethod(); shippingMethodModel.InjectFrom(shippingMethod); var currency = availCurrencies.FirstOrDefault(x=> x.Equals(shippingMethod.Currency)) ?? new Currency(language, shippingMethod.Currency); if (shippingMethod.Discounts != null) { shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel(availCurrencies, language)).ToList(); } shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency); return shippingMethodModel; }
public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod) { var shippingMethodModel = new ShippingMethod(); shippingMethodModel.InjectFrom(shippingMethod); var currency = new Currency(EnumUtility.SafeParse(shippingMethod.Currency, CurrencyCodes.USD)); if (shippingMethod.Discounts != null) { shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel()).ToList(); } shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency.Code); return(shippingMethodModel); }
public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod, IEnumerable <Currency> availCurrencies, Language language) { var shippingMethodModel = new ShippingMethod(); shippingMethodModel.InjectFrom(shippingMethod); var currency = availCurrencies.FirstOrDefault(x => x.Equals(shippingMethod.Currency)) ?? new Currency(language, shippingMethod.Currency); if (shippingMethod.Discounts != null) { shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel(availCurrencies, language)).ToList(); } shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency); return(shippingMethodModel); }
public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod) { var shippingMethodModel = new ShippingMethod(); shippingMethodModel.InjectFrom(shippingMethod); var currency = new Currency(EnumUtility.SafeParse(shippingMethod.Currency, CurrencyCodes.USD)); if (shippingMethod.Discounts != null) { shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel()).ToList(); } shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency.Code); return shippingMethodModel; }