public virtual void DeleteProductCities(ProductCities productcity) { if (productcity == null) throw new ArgumentNullException("productcity"); //delete _productCitiesRepository.Delete(productcity); }
public virtual void AddProductCities(ProductCities productcity) { if (productcity == null) throw new ArgumentNullException("productcity"); //insert _productCitiesRepository.Insert(productcity); }
public ActionResult CityInsert(ProductModel.CityModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); var product = _productService.GetProductById(model.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 city = new ProductCities { ProductID = model.ProductId, CityID = model.CityId, }; _productCitiesService.AddProductCities(city); ////update "HasTierPrices" property //_productService.UpdateHasTierPricesProperty(product); return new NullJsonResult(); }
public ActionResult CityCreatePopup(string btnId, string formId, ProductModel.CityModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCountries)) return AccessDeniedView(); var product = _productService.GetProductById(model.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"); if (model.StateId !=0 && model.CountryId !=0 &&model.CityId!=0 ) { var city = new ProductCities { ProductID = model.ProductId, CityID = model.CityId, }; _productCitiesService.AddProductCities(city); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return View(model); } TempData["message"] = "Please fill up all fields"; //default value model.Countries.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "0" }); foreach (var c in _countryService.GetAllCountries(false)) model.Countries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = (c.Id == 0) }); //model.CountryId = 0; model.States.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Address.SelectState"), Value = "0" }); foreach (var c in _stateProvinceService.GetStateProvincesByCountryId(model.CountryId)) model.States.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = (c.Id == 0) }); //model.StateId = 0; model.Cities.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Address.SelectCity"), Value = "0" }); foreach (var c in _cityService.GetCityByStateProvincesId(model.StateId)) model.Cities.Add(new SelectListItem { Text = c.CityName, Value = c.CityID.ToString(), Selected = (c.CityID == 0) }); model.CityId = 0; //If we got this far, something failed, redisplay form return View(model); }