public IActionResult Edit(StorePickupPointModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Edit(model.Id)); } var pickupPoint = _storePickupPointService.GetStorePickupPointById(model.Id); if (pickupPoint == null) { return(RedirectToAction("Configure")); } var address = _addressService.GetAddressById(pickupPoint.AddressId) ?? new Address { CreatedOnUtc = DateTime.UtcNow }; address.Address1 = model.Address.Address1; address.City = model.Address.City; address.County = model.Address.County; address.CountryId = model.Address.CountryId; address.StateProvinceId = model.Address.StateProvinceId; address.ZipPostalCode = model.Address.ZipPostalCode; if (address.Id > 0) { _addressService.UpdateAddress(address); } else { _addressService.InsertAddress(address); } pickupPoint.Name = model.Name; pickupPoint.Description = model.Description; pickupPoint.AddressId = address.Id; pickupPoint.OpeningHours = model.OpeningHours; pickupPoint.PickupFee = model.PickupFee; pickupPoint.DisplayOrder = model.DisplayOrder; pickupPoint.StoreId = model.StoreId; pickupPoint.Latitude = model.Latitude; pickupPoint.Longitude = model.Longitude; pickupPoint.TransitDays = model.TransitDays; _storePickupPointService.UpdateStorePickupPoint(pickupPoint); ViewBag.RefreshPage = true; return(View("~/Plugins/Pickup.PickupInStore/Views/Edit.cshtml", model)); }
public ActionResult Edit(string btnId, string formId, StorePickupPointModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(Content("Access denied")); } var pickupPoint = _storePickupPointService.GetStorePickupPointById(model.Id); if (pickupPoint == null) { return(RedirectToAction("Configure")); } var address = _addressService.GetAddressById(pickupPoint.AddressId) ?? new Address { CreatedOnUtc = DateTime.UtcNow }; address.Address1 = model.Address.Address1; address.City = model.Address.City; address.CountryId = model.Address.CountryId; address.StateProvinceId = model.Address.StateProvinceId; address.ZipPostalCode = model.Address.ZipPostalCode; if (address.Id > 0) { _addressService.UpdateAddress(address); } else { _addressService.InsertAddress(address); } pickupPoint.Name = model.Name; pickupPoint.Description = model.Description; pickupPoint.AddressId = address.Id; pickupPoint.OpeningHours = model.OpeningHours; pickupPoint.PickupFee = model.PickupFee; pickupPoint.StoreId = model.StoreId; _storePickupPointService.UpdateStorePickupPoint(pickupPoint); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return(View("~/Plugins/Pickup.PickupInStore/Views/Edit.cshtml", model)); }