public ActionResult Edit(string id) { var shippingPoints = _shippingPointService.GetStoreShippingPointById(id); var model = shippingPoints.ToModel(); PrepareShippingPointModel(model); return(View("~/Plugins/Shipping.ShippingPoint/Views/Edit.cshtml", model)); }
public async Task <IActionResult> Edit(string id) { var shippingPoints = await _shippingPointService.GetStoreShippingPointById(id); var model = shippingPoints.ToModel(); await PrepareShippingPointModel(model); return(View(model)); }
public async Task <IActionResult> Get(string shippingOptionId) { var shippingPoint = await _shippingPointService.GetStoreShippingPointById(shippingOptionId); if (shippingPoint != null) { var viewModel = new PointModel() { ShippingPointName = shippingPoint.ShippingPointName, Description = shippingPoint.Description, PickupFee = _priceFormatter.FormatShippingPrice(shippingPoint.PickupFee), OpeningHours = shippingPoint.OpeningHours, Address1 = shippingPoint.Address1, City = shippingPoint.City, CountryName = (await _countryService.GetCountryById(shippingPoint.CountryId))?.Name, ZipPostalCode = shippingPoint.ZipPostalCode, }; return(View(viewModel)); } return(Content("ShippingPointController: given Shipping Option doesn't exist")); }
public IActionResult Get(string shippingOptionId) { var shippingPoint = _shippingPointService.GetStoreShippingPointById(shippingOptionId); if (shippingPoint != null) { var countryName = _countryService.GetCountryById(shippingPoint.CountryId); var viewModel = new PointModel() { ShippingPointName = shippingPoint.ShippingPointName, Description = shippingPoint.Description, PickupFee = _priceFormatter.FormatShippingPrice(shippingPoint.PickupFee, true), OpeningHours = shippingPoint.OpeningHours, Address1 = shippingPoint.Address1, City = shippingPoint.City, CountryName = _countryService.GetCountryById(shippingPoint.CountryId)?.Name, ZipPostalCode = shippingPoint.ZipPostalCode, }; return(View("~/Plugins/Shipping.ShippingPoint/Views/FormShippingOption.cshtml", viewModel)); } return(Content("ShippingPointController: given Shipping Option doesn't exist")); }
public IList <string> ValidateShippingForm(IFormCollection form) { var shippingMethodName = form["shippingoption"].ToString().Replace("___", "_").Split(new[] { '_' })[0]; var shippingOptionId = form["selectedShippingOption"].ToString(); if (string.IsNullOrEmpty(shippingOptionId)) { return new List <string>() { _localizationService.GetResource("Plugins.Shipping.ShippingPoint.SelectBeforeProceed") } } ; if (shippingMethodName != _localizationService.GetResource("Plugins.Shipping.ShippingPoint.PluginName")) { throw new ArgumentException("shippingMethodName"); } var chosenShippingOption = _shippingPointService.GetStoreShippingPointById(shippingOptionId); if (chosenShippingOption == null) { return new List <string>() { _localizationService.GetResource("Plugins.Shipping.ShippingPoint.SelectBeforeProceed") } } ; //override price var offeredShippingOptions = _workContext.CurrentCustomer.GetAttribute <List <ShippingOption> >(SystemCustomerAttributeNames.OfferedShippingOptions, _storeContext.CurrentStore.Id); offeredShippingOptions.Find(x => x.Name == shippingMethodName).Rate = chosenShippingOption.PickupFee; _genericAttributeService.SaveAttribute( _workContext.CurrentCustomer, SystemCustomerAttributeNames.OfferedShippingOptions, offeredShippingOptions, _storeContext.CurrentStore.Id); var forCustomer = string.Format("<strong>{0}:</strong> {1}<br><strong>{2}:</strong> {3}<br>", _localizationService.GetResource("Plugins.Shipping.ShippingPoint.Fields.ShippingPointName"), chosenShippingOption.ShippingPointName, _localizationService.GetResource("Plugins.Shipping.ShippingPoint.Fields.Description"), chosenShippingOption.Description ); _genericAttributeService.SaveAttribute( _workContext.CurrentCustomer, SystemCustomerAttributeNames.ShippingOptionAttributeDescription, forCustomer, _storeContext.CurrentStore.Id); var serializedObject = new Domain.ShippingPointSerializable() { Id = chosenShippingOption.Id, ShippingPointName = chosenShippingOption.ShippingPointName, Description = chosenShippingOption.Description, OpeningHours = chosenShippingOption.OpeningHours, PickupFee = chosenShippingOption.PickupFee, Country = _countryService.GetCountryById(chosenShippingOption.CountryId)?.Name, City = chosenShippingOption.City, Address1 = chosenShippingOption.Address1, ZipPostalCode = chosenShippingOption.ZipPostalCode, StoreId = chosenShippingOption.StoreId, }; var stringBuilder = new StringBuilder(); string serializedAttribute; using (var tw = new StringWriter(stringBuilder)) { var xmlS = new XmlSerializer(typeof(Domain.ShippingPointSerializable)); xmlS.Serialize(tw, serializedObject); serializedAttribute = stringBuilder.ToString(); } _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.ShippingOptionAttributeXml, serializedAttribute, _storeContext.CurrentStore.Id); return(new List <string>()); }