From 53c7ba7937af03b9fae96621c89d315a9a6c03fb Mon Sep 17 00:00:00 2001 From: Tatarincev Date: Mon, 4 Jul 2016 12:42:29 +0200 Subject: [PATCH 1/2] Use page_size from query sting for data pagination Use resp_group from query string for product details https://github.com/VirtoCommerce/vc-platform/issues/534 https://github.com/VirtoCommerce/vc-platform/issues/530 --- .../Converters/ShopifyContextConverter.cs | 3 ++- .../Objects/ShopifyThemeWorkContext.cs | 1 + VirtoCommerce.LiquidThemeEngine/Tags/PaginateTag.cs | 5 +++-- .../Catalog/CatalogSearchCriteria.cs | 4 ++-- .../Common/PagedSearchCriteria.cs | 5 +++-- .../Common/StringExtensions.cs | 10 ++++++++++ VirtoCommerce.Storefront.Model/WorkContext.cs | 13 +++++++++++++ .../Controllers/ProductController.cs | 7 +------ .../Owin/WorkContextOwinMiddleware.cs | 5 +++++ .../Services/CatalogSearchServiceImpl.cs | 6 +++++- 10 files changed, 45 insertions(+), 14 deletions(-) diff --git a/VirtoCommerce.LiquidThemeEngine/Converters/ShopifyContextConverter.cs b/VirtoCommerce.LiquidThemeEngine/Converters/ShopifyContextConverter.cs index 8eadf242..de9f2837 100644 --- a/VirtoCommerce.LiquidThemeEngine/Converters/ShopifyContextConverter.cs +++ b/VirtoCommerce.LiquidThemeEngine/Converters/ShopifyContextConverter.cs @@ -145,7 +145,8 @@ public static ShopifyThemeWorkContext ToShopifyModel(this storefrontModel.WorkCo result.RequestUrl = workContext.RequestUrl.ToString(); //Populate current page number var qs = HttpUtility.ParseQueryString(workContext.RequestUrl.Query); - result.CurrentPage = Convert.ToInt32(qs.Get("page") ?? 1.ToString()); + result.CurrentPage = workContext.PageNumber ?? 1; + result.PageSize = workContext.PageSize ?? 0; } return result; } diff --git a/VirtoCommerce.LiquidThemeEngine/Objects/ShopifyThemeWorkContext.cs b/VirtoCommerce.LiquidThemeEngine/Objects/ShopifyThemeWorkContext.cs index d79fae89..00a7c880 100644 --- a/VirtoCommerce.LiquidThemeEngine/Objects/ShopifyThemeWorkContext.cs +++ b/VirtoCommerce.LiquidThemeEngine/Objects/ShopifyThemeWorkContext.cs @@ -84,6 +84,7 @@ public class ShopifyThemeWorkContext : ILiquidizable public Collections Collections { get; set; } public int CurrentPage { get; set; } + public int PageSize { get; set; } public TagCollection CurrentTags { get; set; } diff --git a/VirtoCommerce.LiquidThemeEngine/Tags/PaginateTag.cs b/VirtoCommerce.LiquidThemeEngine/Tags/PaginateTag.cs index 1894ff08..aa41d536 100644 --- a/VirtoCommerce.LiquidThemeEngine/Tags/PaginateTag.cs +++ b/VirtoCommerce.LiquidThemeEngine/Tags/PaginateTag.cs @@ -59,10 +59,11 @@ public override void Render(Context context, TextWriter result) Uri requestUrl; Uri.TryCreate(context["request_url"] as string, UriKind.RelativeOrAbsolute, out requestUrl); var pageNumber = (int)context["current_page"]; - + var pageSize = (int)context["page_size"]; + if (mutablePagedList != null) { - mutablePagedList.Slice(pageNumber, _pageSize > 0 ? _pageSize : 20); + mutablePagedList.Slice(pageNumber, pageSize > 0 ? pageSize : _pageSize); pagedList = mutablePagedList; } else if (collection != null) diff --git a/VirtoCommerce.Storefront.Model/Catalog/CatalogSearchCriteria.cs b/VirtoCommerce.Storefront.Model/Catalog/CatalogSearchCriteria.cs index dd82e111..21d7b682 100644 --- a/VirtoCommerce.Storefront.Model/Catalog/CatalogSearchCriteria.cs +++ b/VirtoCommerce.Storefront.Model/Catalog/CatalogSearchCriteria.cs @@ -22,8 +22,7 @@ public CatalogSearchCriteria(Language language, Currency currency, NameValueColl : base(queryString) { Language = language; - Currency = currency; - ResponseGroup = CatalogSearchResponseGroup.WithProducts | CatalogSearchResponseGroup.WithCategories | CatalogSearchResponseGroup.WithProperties | CatalogSearchResponseGroup.WithOutlines; + Currency = currency; SearchInChildren = true; Parse(queryString); @@ -66,6 +65,7 @@ private void Parse(NameValueCollection queryString) //TODO move this code to Parse or Converter method // tags=name1:value1,value2,value3;name2:value1,value2,value3 SearchInChildren = Convert.ToBoolean(queryString.Get("deep_search") ?? SearchInChildren.ToString()); + ResponseGroup = EnumUtility.SafeParse(queryString.Get("resp_group"), CatalogSearchResponseGroup.WithProducts | CatalogSearchResponseGroup.WithCategories | CatalogSearchResponseGroup.WithProperties | CatalogSearchResponseGroup.WithOutlines); SortBy = queryString.Get("sort_by"); Terms = (queryString.GetValues("terms") ?? new string[0]) .SelectMany(s => s.Split(';')) diff --git a/VirtoCommerce.Storefront.Model/Common/PagedSearchCriteria.cs b/VirtoCommerce.Storefront.Model/Common/PagedSearchCriteria.cs index 8f97ffb0..9fac40d0 100644 --- a/VirtoCommerce.Storefront.Model/Common/PagedSearchCriteria.cs +++ b/VirtoCommerce.Storefront.Model/Common/PagedSearchCriteria.cs @@ -8,12 +8,13 @@ namespace VirtoCommerce.Storefront.Model.Common { public class PagedSearchCriteria - { + { public PagedSearchCriteria(NameValueCollection queryString) { PageNumber = Convert.ToInt32(queryString.Get("page") ?? 1.ToString()); - PageSize = Convert.ToInt32(queryString.Get("count") ?? 10.ToString()); + PageSize = Convert.ToInt32(queryString.Get("count") ?? queryString.Get("page_size") ?? 20.ToString()); } + public int Start { get diff --git a/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs b/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs index 8785f7b8..3bd11d47 100644 --- a/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs +++ b/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs @@ -45,5 +45,15 @@ public static bool FitsMask(this string fileName, string fileMask) var mask = new Regex(fileMask.Replace(".", "[.]").Replace("*", ".*").Replace("?", "."), RegexOptions.IgnoreCase); return mask.IsMatch(fileName); } + + public static int? ToNullableInt(this string str) + { + int retVal; + if (int.TryParse(str, out retVal)) + { + return retVal; + } + return null; + } } } diff --git a/VirtoCommerce.Storefront.Model/WorkContext.cs b/VirtoCommerce.Storefront.Model/WorkContext.cs index 17e9260c..37d1fafe 100644 --- a/VirtoCommerce.Storefront.Model/WorkContext.cs +++ b/VirtoCommerce.Storefront.Model/WorkContext.cs @@ -136,6 +136,10 @@ public SeoInfo CurrentPageSeo /// Current search catalog criterias /// public CatalogSearchCriteria CurrentCatalogSearchCriteria { get; set; } + /// + /// Current product response group + /// + public ItemResponseGroup CurrentProductResponseGroup { get; set; } #endregion @@ -194,6 +198,15 @@ public DateTime StorefrontUtcNow /// public IDictionary ApplicationSettings { get; set; } + /// + /// Current page number + /// + public int? PageNumber { get; set; } + /// + /// Current page size + /// + public int? PageSize { get; set; } + #region IDisposable Implementation public void Dispose() diff --git a/VirtoCommerce.Storefront/Controllers/ProductController.cs b/VirtoCommerce.Storefront/Controllers/ProductController.cs index 4ffe6037..bc806c3a 100644 --- a/VirtoCommerce.Storefront/Controllers/ProductController.cs +++ b/VirtoCommerce.Storefront/Controllers/ProductController.cs @@ -33,12 +33,7 @@ public ProductController(WorkContext context, IStorefrontUrlBuilder urlBuilder, [HttpGet] public async Task ProductDetails(string productId) { - var product = (await _catalogSearchService.GetProductsAsync(new[] { productId }, - Model.Catalog.ItemResponseGroup.Variations | - Model.Catalog.ItemResponseGroup.ItemProperties | - Model.Catalog.ItemResponseGroup.ItemSmall | - Model.Catalog.ItemResponseGroup.ItemWithPrices | - Model.Catalog.ItemResponseGroup.ItemAssociations)).FirstOrDefault(); + var product = (await _catalogSearchService.GetProductsAsync(new[] { productId }, WorkContext.CurrentProductResponseGroup)).FirstOrDefault(); WorkContext.CurrentProduct = product; if(product.CategoryId != null) diff --git a/VirtoCommerce.Storefront/Owin/WorkContextOwinMiddleware.cs b/VirtoCommerce.Storefront/Owin/WorkContextOwinMiddleware.cs index cecb2140..5358055e 100644 --- a/VirtoCommerce.Storefront/Owin/WorkContextOwinMiddleware.cs +++ b/VirtoCommerce.Storefront/Owin/WorkContextOwinMiddleware.cs @@ -102,6 +102,11 @@ public override async Task Invoke(IOwinContext context) { CatalogId = workContext.CurrentStore.Catalog }; + //Initialize product response group + workContext.CurrentProductResponseGroup = EnumUtility.SafeParse(qs.Get("resp_group"), ItemResponseGroup.ItemLarge); + + workContext.PageNumber = qs.Get("page").ToNullableInt(); + workContext.PageSize = qs.Get("count").ToNullableInt() ?? qs.Get("page_size").ToNullableInt(); //This line make delay categories loading initialization (categories can be evaluated on view rendering time) workContext.Categories = new MutablePagedList((pageNumber, pageSize) => diff --git a/VirtoCommerce.Storefront/Services/CatalogSearchServiceImpl.cs b/VirtoCommerce.Storefront/Services/CatalogSearchServiceImpl.cs index 11c25ccd..efffc3fe 100644 --- a/VirtoCommerce.Storefront/Services/CatalogSearchServiceImpl.cs +++ b/VirtoCommerce.Storefront/Services/CatalogSearchServiceImpl.cs @@ -36,9 +36,13 @@ public CatalogSearchServiceImpl(Func workContextFactory, IVirtoComm } #region ICatalogSearchService Members - public async Task GetProductsAsync(string[] ids, ItemResponseGroup responseGroup = ItemResponseGroup.ItemInfo) + public async Task GetProductsAsync(string[] ids, ItemResponseGroup responseGroup = ItemResponseGroup.None) { var workContext = _workContextFactory(); + if(responseGroup == ItemResponseGroup.None) + { + responseGroup = workContext.CurrentProductResponseGroup; + } var retVal = (await _catalogModuleApi.CatalogModuleProductsGetProductByIdsAsync(ids.ToList(), ((int)responseGroup).ToString())).Select(x => x.ToWebModel(workContext.CurrentLanguage, workContext.CurrentCurrency, workContext.CurrentStore)).ToArray(); From a6eb0d62a0d5062ae52364116d73de1061ccd2cb Mon Sep 17 00:00:00 2001 From: Tatarincev Date: Mon, 4 Jul 2016 17:52:55 +0200 Subject: [PATCH 2/2] Refactoring some tax logic --- .../Cart/LineItem.cs | 12 ++++-- .../Cart/Shipment.cs | 11 ++++-- .../Catalog/Product.cs | 12 ++++-- .../Common/StringExtensions.cs | 12 ++++++ .../ShippingMethod.cs | 2 +- .../Builders/CartBuilder.cs | 1 - .../TaxEvaluationContextConverter.cs | 38 +++++++++---------- 7 files changed, 55 insertions(+), 33 deletions(-) diff --git a/VirtoCommerce.Storefront.Model/Cart/LineItem.cs b/VirtoCommerce.Storefront.Model/Cart/LineItem.cs index 1cac2d56..614b03c8 100644 --- a/VirtoCommerce.Storefront.Model/Cart/LineItem.cs +++ b/VirtoCommerce.Storefront.Model/Cart/LineItem.cs @@ -334,13 +334,17 @@ public Money DiscountTotalWithTax public void ApplyTaxRates(IEnumerable taxRates) { - var lineItemTaxRates = taxRates.Where(x => x.Line.Id == Id); + ListPriceWithTax = ListPrice; + SalePriceWithTax = SalePrice; + + //Because TaxLine.Id may contains composite string id & extra info + var lineItemTaxRates = taxRates.Where(x => x.Line.Id.SplitIntoTuple('&').Item1 == Id); TaxTotal = new Money(Currency); if (lineItemTaxRates.Any()) { - var extendedPriceRate = lineItemTaxRates.First(x => x.Line.Code.EqualsInvariant("extended")); - var listPriceRate = lineItemTaxRates.First(x => x.Line.Code.EqualsInvariant("list")); - var salePriceRate = lineItemTaxRates.FirstOrDefault(x => x.Line.Code.EqualsInvariant("sale")); + var extendedPriceRate = lineItemTaxRates.First(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("extended")); + var listPriceRate = lineItemTaxRates.First(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("list")); + var salePriceRate = lineItemTaxRates.FirstOrDefault(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("sale")); if (salePriceRate == null) { salePriceRate = listPriceRate; diff --git a/VirtoCommerce.Storefront.Model/Cart/Shipment.cs b/VirtoCommerce.Storefront.Model/Cart/Shipment.cs index 5d691235..ee768cee 100644 --- a/VirtoCommerce.Storefront.Model/Cart/Shipment.cs +++ b/VirtoCommerce.Storefront.Model/Cart/Shipment.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using VirtoCommerce.Storefront.Model.Cart.Services; using VirtoCommerce.Storefront.Model.Cart.ValidationErrors; @@ -215,12 +216,14 @@ public Money SubtotalWithTax public void ApplyTaxRates(IEnumerable taxRates) { - var shipmentTaxRates = taxRates.Where(x=>x.Line.Id == Id); + ShippingPriceWithTax = ShippingPrice; + //Because TaxLine.Id may contains composite string id & extra info + var shipmentTaxRates = taxRates.Where(x => x.Line.Id.SplitIntoTuple('&').Item1 == Id); TaxTotal = new Money(Currency); if(shipmentTaxRates.Any()) { - var totalTaxRate = shipmentTaxRates.First(x => x.Line.Code.EqualsInvariant("total")); - var priceTaxRate = shipmentTaxRates.First(x => x.Line.Code.EqualsInvariant("price")); + var totalTaxRate = shipmentTaxRates.First(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("total")); + var priceTaxRate = shipmentTaxRates.First(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("price")); TaxTotal += totalTaxRate.Rate; ShippingPriceWithTax = ShippingPrice + priceTaxRate.Rate; } diff --git a/VirtoCommerce.Storefront.Model/Catalog/Product.cs b/VirtoCommerce.Storefront.Model/Catalog/Product.cs index 46b07047..56363f11 100644 --- a/VirtoCommerce.Storefront.Model/Catalog/Product.cs +++ b/VirtoCommerce.Storefront.Model/Catalog/Product.cs @@ -310,12 +310,16 @@ public void ApplyPrices(IEnumerable prices, Currency currentCurren public void ApplyTaxRates(IEnumerable taxRates) { - var productTaxRates = taxRates.Where(x => x.Line.Id == Id); + Price.ListPriceWithTax = Price.ListPrice; + Price.SalePriceWithTax = Price.SalePrice; + + //Because TaxLine.Id may contains composite string id & extra info + var productTaxRates = taxRates.Where(x => x.Line.Id.SplitIntoTuple('&').Item1 == Id); TaxTotal = new Money(Currency); if (productTaxRates.Any()) { - var listPriceRate = productTaxRates.First(x => x.Line.Code.EqualsInvariant("list")); - var salePriceRate = productTaxRates.FirstOrDefault(x => x.Line.Code.EqualsInvariant("sale")); + var listPriceRate = productTaxRates.First(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("list")); + var salePriceRate = productTaxRates.FirstOrDefault(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant("sale")); if(salePriceRate == null) { salePriceRate = listPriceRate; @@ -327,7 +331,7 @@ public void ApplyTaxRates(IEnumerable taxRates) //Apply tax for tier prices foreach (var tierPrice in Price.TierPrices) { - var tierPriceTaxRate = productTaxRates.FirstOrDefault(x => x.Line.Code.EqualsInvariant(tierPrice.Quantity.ToString())); + var tierPriceTaxRate = productTaxRates.FirstOrDefault(x => x.Line.Id.SplitIntoTuple('&').Item2.EqualsInvariant(tierPrice.Quantity.ToString())); if(tierPrice != null) { tierPrice.Tax = tierPriceTaxRate.Rate; diff --git a/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs b/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs index 3bd11d47..8db0783e 100644 --- a/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs +++ b/VirtoCommerce.Storefront.Model/Common/StringExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -55,5 +56,16 @@ public static bool FitsMask(this string fileName, string fileMask) } return null; } + + public static Tuple SplitIntoTuple(this string input, char separator) + { + if(input == null) + { + throw new ArgumentNullException("input"); + } + + var pieces = input.Split(separator); + return Tuple.Create(pieces.FirstOrDefault(), pieces.Skip(1).FirstOrDefault()); + } } } diff --git a/VirtoCommerce.Storefront.Model/ShippingMethod.cs b/VirtoCommerce.Storefront.Model/ShippingMethod.cs index e1a13398..3c0539b1 100644 --- a/VirtoCommerce.Storefront.Model/ShippingMethod.cs +++ b/VirtoCommerce.Storefront.Model/ShippingMethod.cs @@ -125,7 +125,7 @@ public Money DiscountTotalWithTax public void ApplyTaxRates(IEnumerable taxRates) { - var shippingMethodTaxRates = taxRates.Where(x => x.Line.Id == ShipmentMethodCode); + var shippingMethodTaxRates = taxRates.Where(x => x.Line.Id.SplitIntoTuple('&').Item1 == ShipmentMethodCode && x.Line.Id.SplitIntoTuple('&').Item2 == OptionName); TaxTotal = new Money(Currency); var shippingMethodTaxRate = shippingMethodTaxRates.FirstOrDefault(); diff --git a/VirtoCommerce.Storefront/Builders/CartBuilder.cs b/VirtoCommerce.Storefront/Builders/CartBuilder.cs index 7fb9f2b8..fd76e4a5 100644 --- a/VirtoCommerce.Storefront/Builders/CartBuilder.cs +++ b/VirtoCommerce.Storefront/Builders/CartBuilder.cs @@ -440,7 +440,6 @@ public virtual async Task> GetAvailableShippingMetho } //Evaluate tax for shipping methods var taxEvalContext = _cart.ToTaxEvalContext(); - taxEvalContext.Lines.Clear(); taxEvalContext.Lines.AddRange(availableShippingMethods.Select(x => x.ToTaxLine())); var taxResult = await _commerceApi.CommerceEvaluateTaxesAsync(_cart.StoreId, taxEvalContext); if (taxResult != null) diff --git a/VirtoCommerce.Storefront/Converters/TaxEvaluationContextConverter.cs b/VirtoCommerce.Storefront/Converters/TaxEvaluationContextConverter.cs index b05bcd2f..20f4b062 100644 --- a/VirtoCommerce.Storefront/Converters/TaxEvaluationContextConverter.cs +++ b/VirtoCommerce.Storefront/Converters/TaxEvaluationContextConverter.cs @@ -13,9 +13,9 @@ public static coreModel.TaxLine ToTaxLine(this ShippingMethod shipmentMethod) { var retVal = new coreModel.TaxLine { - Id = shipmentMethod.ShipmentMethodCode, - Code = shipmentMethod.ShipmentMethodCode, - Name = shipmentMethod.ShipmentMethodCode, + Id = string.Join("&", shipmentMethod.ShipmentMethodCode, shipmentMethod.OptionName), + Code = string.Join("&", shipmentMethod.ShipmentMethodCode, shipmentMethod.OptionName), + Name = string.Join("&", shipmentMethod.Name, shipmentMethod.OptionDescription), TaxType = shipmentMethod.TaxType, Amount = (double)shipmentMethod.Price.Amount }; @@ -28,8 +28,8 @@ public static coreModel.TaxLine[] ToListAndSaleTaxLines(this Product product) { new coreModel.TaxLine { - Id = product.Id, - Code = "list", + Id = product.Id + "&list", + Code = product.Sku, Name = product.Name, TaxType = product.TaxType, Amount = (double) product.Price.ListPrice.Amount @@ -41,8 +41,8 @@ public static coreModel.TaxLine[] ToListAndSaleTaxLines(this Product product) { retVal.Add(new coreModel.TaxLine { - Id = product.Id, - Code = "sale", + Id = product.Id + "&sale", + Code = product.Sku, Name = product.Name, TaxType = product.TaxType, Amount = (double)product.Price.SalePrice.Amount @@ -54,8 +54,8 @@ public static coreModel.TaxLine[] ToListAndSaleTaxLines(this Product product) { retVal.Add(new coreModel.TaxLine { - Id = product.Id, - Code = tierPrice.Quantity.ToString(), + Id = product.Id + "&" + tierPrice.Quantity.ToString(), + Code = product.Sku, Name = product.Name, TaxType = product.TaxType, Amount = (double)tierPrice.Price.Amount @@ -101,8 +101,8 @@ public static coreModel.TaxEvaluationContext ToTaxEvalContext(this ShoppingCart { var extendedTaxLine = new coreModel.TaxLine { - Id = lineItem.Id, - Code = "extended", + Id = lineItem.Id + "&extended", + Code = lineItem.Sku, Name = lineItem.Name, TaxType = lineItem.TaxType, Amount = (double)lineItem.ExtendedPrice.Amount @@ -111,8 +111,8 @@ public static coreModel.TaxEvaluationContext ToTaxEvalContext(this ShoppingCart var listTaxLine = new coreModel.TaxLine { - Id = lineItem.Id, - Code = "list", + Id = lineItem.Id + "&list", + Code = lineItem.Sku, Name = lineItem.Name, TaxType = lineItem.TaxType, Amount = (double)lineItem.ListPrice.Amount @@ -123,8 +123,8 @@ public static coreModel.TaxEvaluationContext ToTaxEvalContext(this ShoppingCart { var saleTaxLine = new coreModel.TaxLine { - Id = lineItem.Id, - Code = "sale", + Id = lineItem.Id + "&sale", + Code = lineItem.Sku, Name = lineItem.Name, TaxType = lineItem.TaxType, Amount = (double)lineItem.SalePrice.Amount @@ -137,8 +137,8 @@ public static coreModel.TaxEvaluationContext ToTaxEvalContext(this ShoppingCart { var totalTaxLine = new coreModel.TaxLine { - Id = shipment.Id, - Code = "total", + Id = shipment.Id + "&total", + Code = shipment.ShipmentMethodCode, Name = shipment.ShipmentMethodCode, TaxType = shipment.TaxType, Amount = (double)shipment.Total.Amount @@ -146,8 +146,8 @@ public static coreModel.TaxEvaluationContext ToTaxEvalContext(this ShoppingCart retVal.Lines.Add(totalTaxLine); var priceTaxLine = new coreModel.TaxLine { - Id = shipment.Id, - Code = "price", + Id = shipment.Id + "&price", + Code = shipment.ShipmentMethodCode, Name = shipment.ShipmentMethodCode, TaxType = shipment.TaxType, Amount = (double)shipment.ShippingPrice.Amount