private void Initialize(ShippingRatesViewModel viewModel) { viewModel.NumberFormat = this._webStoreServices.NumberFormat; this._webStoreServices.UsingClient(c => viewModel.ShippingRatesByPackage = c.StoreClient.GetShippingRateValues("default")); }
public ActionResult SetShippingRates(ShippingRatesViewModel viewModel) { if (this.ModelState.IsValid) { String basketHash = null; Exception exception = this._webStoreServices.UsingClient(c => { c.StoreClient.SetShippingRateValues("default", viewModel.ShippingRateValueSelections.ToDictionary(srvs => srvs.PackageId, srvs => srvs.ShippingRateValueId.Value)); basketHash = c.StoreClient.GetBasketHash("default"); } ); return this.Json(new { success = exception == null, basketHash = basketHash }); } else { this.Initialize(viewModel); return this.BuildShippingRatesShapeResult(viewModel); } }
private ActionResult BuildShippingRatesShapeResult(ShippingRatesViewModel viewModel) { return new ShapePartialResult(this, this._shapeFactory.EditorTemplate(TemplateName: "Checkout/ShippingRates", Model: viewModel)); }
public ActionResult EditShippingRates() { Basket basket = null; ShippingRatesViewModel viewModel = new ShippingRatesViewModel(); this.Initialize(viewModel); this._webStoreServices.UsingClient(c => basket = c.StoreClient.GetBasket("default")); viewModel.ShippingRateValueSelections = viewModel.ShippingRatesByPackage.Select(srbp => new ShippingRatesViewModel.ShippingRateValueSelection { PackageId = srbp.Key, ShippingRateValueId = srbp.Value.OrderByDescending(srv => basket != null && basket.Packages.Where(p => p.PackageId == srbp.Key).Any(p => p.ShippingRateCode.EqualsInvariantCultureIgnoreCase(srv.ShippingRateCode))).Select(srv => srv.ShippingRateValueId).Cast<Nullable<Guid>>().FirstOrDefault() }).ToList(); this.Response.Cache.SetCacheability(HttpCacheability.NoCache); return this.BuildShippingRatesShapeResult(viewModel); }