Exemple #1
0
        /// <summary>
        /// Deletes a state/province
        /// </summary>
        /// <param name="stateProvince">The state/province</param>
        public virtual void DeleteCity(City city)
        {
            if (city == null)
                throw new ArgumentNullException("stateProvince");
            
            _cityRepository.Delete(city);

            _cacheManager.RemoveByPattern(CITY_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityDeleted(city);
        }
 protected virtual CityModel PrepareCityModelForList(City city)
 {
     return new CityModel
     {
         Id = city.CityID,
         CityID = city.CityID,
         CityName = city.CityName,
         StateID = city.StateID,
         StateName = city.StateProvince.Name,
     };
 }
        protected virtual void PrepareCityModel(CityModel model, City country, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            //model.AvailableStores = _storeService
            //    .GetAllStores()
            //    .Select(s => s.ToModel())
            //    .ToList();
            if (!excludeProperties)
            {
                if (country != null)
                {
                    //model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(country);
                }
            }
        }
 protected virtual void UpdateLocales(City city, CityModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(city,
                                                        x => x.CityName,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
Exemple #5
0
        /// <summary>
        /// Inserts a state/province
        /// </summary>
        /// <param name="stateProvince">State/province</param>
        public virtual void InsertCity(City city)
        {
            if (city == null)
                throw new ArgumentNullException("city");

            _cityRepository.Insert(city);

            _cacheManager.RemoveByPattern(CITY_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityInserted(city);
        }
        public ActionResult CityList(DataSourceRequest command, int productId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
                return AccessDeniedView();

            var product = _productService.GetProductById(productId);
            if (product == null)
                throw new ArgumentException("No product found with the specified id");

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id)
                return Content("This is not your product");
            var Cities = _productCitiesService.GetProductsCitiesByProductId(productId);
            List<ProductModel.CityModel> citymodel = new List<ProductModel.CityModel>();
            foreach (var c in Cities)
            {
                if (c != null)
                {
                    ProductModel.CityModel city = new ProductModel.CityModel();
                    string countryName;
                    var state = new StateProvince();
                    var country = new Country();
                    var cty = new City();
                    if (c.CityID > 0)
                    {
                        cty = _cityService.GetCityById(c.CityID);
                        state = _stateProvinceService.GetStateProvinceById(cty.StateID);
                        country = _countryService.GetCountryById(state.Id);
                        countryName = country != null ? country.Name : "Deleted";
                    }
                    else
                    {
                        countryName = _localizationService.GetResource("Admin.Catalog.Products.City.Fields.Country.All");
                    }

                    city.Id = c.Id;
                    city.CityId = c.CityID;
                    city.City = cty.CityName;
                    city.CountryId = country != null ? country.Id : 0;
                    city.Country = country != null ? country.Name : "Deleted";
                    city.StateId = state != null ? state.Id : 0;
                    city.State = state != null ? state.Name : "Deleted";
                    city.ProductId = c.ProductID;
                    citymodel.Add(city);
                }
            }
            var gridModel = new DataSourceResult
            {
                Data = citymodel,
                Total = citymodel.Count
            };
            return Json(gridModel);
        }