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

            var pickupPoint = await _storePickupPointService.GetStorePickupPointByIdAsync(id);

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

            var model = new StorePickupPointModel
            {
                Id           = pickupPoint.Id,
                Name         = pickupPoint.Name,
                Description  = pickupPoint.Description,
                OpeningHours = pickupPoint.OpeningHours,
                PickupFee    = pickupPoint.PickupFee,
                DisplayOrder = pickupPoint.DisplayOrder,
                StoreId      = pickupPoint.StoreId,
                Latitude     = pickupPoint.Latitude,
                Longitude    = pickupPoint.Longitude,
                TransitDays  = pickupPoint.TransitDays
            };

            var address = await _addressService.GetAddressByIdAsync(pickupPoint.AddressId);

            if (address != null)
            {
                model.Address = new AddressModel
                {
                    Address1        = address.Address1,
                    City            = address.City,
                    County          = address.County,
                    CountryId       = address.CountryId,
                    StateProvinceId = address.StateProvinceId,
                    ZipPostalCode   = address.ZipPostalCode,
                };
            }

            model.Address.AvailableCountries.Add(new SelectListItem {
                Text = await _localizationService.GetResourceAsync("Admin.Address.SelectCountry"), Value = "0"
            });
            foreach (var country in await _countryService.GetAllCountriesAsync(showHidden: true))
            {
                model.Address.AvailableCountries.Add(new SelectListItem {
                    Text = country.Name, Value = country.Id.ToString(), Selected = (address != null && country.Id == address.CountryId)
                });
            }

            var states = !model.Address.CountryId.HasValue ? new List <StateProvince>()
                : await _stateProvinceService.GetStateProvincesByCountryIdAsync(model.Address.CountryId.Value, showHidden : true);

            if (states.Any())
            {
                model.Address.AvailableStates.Add(new SelectListItem {
                    Text = await _localizationService.GetResourceAsync("Admin.Address.SelectState"), Value = "0"
                });
                foreach (var state in states)
                {
                    model.Address.AvailableStates.Add(new SelectListItem {
                        Text = state.Name, Value = state.Id.ToString(), Selected = (address != null && state.Id == address.StateProvinceId)
                    });
                }
            }
            else
            {
                model.Address.AvailableStates.Add(new SelectListItem {
                    Text = await _localizationService.GetResourceAsync("Admin.Address.Other"), Value = "0"
                });
            }

            model.AvailableStores.Add(new SelectListItem {
                Text = await _localizationService.GetResourceAsync("Admin.Configuration.Settings.StoreScope.AllStores"), Value = "0"
            });
            foreach (var store in await _storeService.GetAllStoresAsync())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString(), Selected = store.Id == model.StoreId
                });
            }

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