Exemple #1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ShippingZone shippingZone = shippingZoneService.Find(id.Value);

            if (shippingZone == null)
            {
                return(HttpNotFound());
            }
            var model = Mapper.Map <ShippingZoneEditViewModel>(shippingZone);

            string[] countryCodes = shippingZone.Countries.Select(c => c.Code).ToArray();
            model.CountryCodesJson = JsonConvert.SerializeObject(countryCodes);

            int[] regionIds = shippingZone.Regions.Select(r => r.Id).ToArray();
            model.RegionIdsJson = JsonConvert.SerializeObject(regionIds);

            ViewBag.Countries = countryService.FindAll().Where(c => c.IsActive || countryCodes.Contains(c.Code)).ToList();
            return(View(model));
        }
Exemple #2
0
 public ShippingZone FindZone(string countryCode, int?regionId)
 {
     return(shippingZoneService.Find(countryCode, regionId));
 }