/// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> Edit(StorePickupPointModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(await Edit(model.Id));
            }

            var pickupPoint = await _storePickupPointService.GetStorePickupPointByIdAsync(model.Id);

            if (pickupPoint == null)
            {
                return(RedirectToAction("Configure"));
            }

            var address = await _addressService.GetAddressByIdAsync(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)
            {
                await _addressService.UpdateAddressAsync(address);
            }
            else
            {
                await _addressService.InsertAddressAsync(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;
            await _storePickupPointService.UpdateStorePickupPointAsync(pickupPoint);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Pickup.PickupInStore/Views/Edit.cshtml", model));
        }