public ActionResult VendorManufacturerUpdate(VendorModel.VendorManufacturerModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors)) { return(AccessDeniedView()); } var vendorManufacturer = _manufacturerService.GetVendorManufacturerById(model.Id); if (vendorManufacturer == null) { throw new ArgumentException("No vendor manufacturer mapping found with the specified id"); } //a vendor should have access only to his products //if (_workContext.CurrentVendor != null) //{ // var product = _productService.GetProductById(productManufacturer.ProductId); // if (product != null && product.VendorId != _workContext.CurrentVendor.Id) // { // return Content("This is not your product"); // } //} vendorManufacturer.VendorId = model.VendorId; vendorManufacturer.ManufacturerId = model.ManufacturerId; vendorManufacturer.DiscountPercentage = model.DiscountPercentage; //a vendor cannot edit "IsFeaturedProduct" property //if (_workContext.CurrentVendor == null) //{ // productManufacturer.IsFeaturedProduct = model.IsFeaturedProduct; //} _manufacturerService.UpdateVendorManufacturer(vendorManufacturer); return(new NullJsonResult()); }
public ActionResult VendorManufacturerInsert(VendorModel.VendorManufacturerModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors)) { return(AccessDeniedView()); } var vendorId = model.VendorId; var manufacturerId = model.ManufacturerId; //a vendor should have access only to his products //if (_workContext.CurrentVendor != null) //{ // var product = _productService.GetProductById(productId); // if (product != null && product.VendorId != _workContext.CurrentVendor.Id) // { // return Content("This is not your product"); // } //} var existingVendormanufacturers = _manufacturerService.GetVendorManufacturersByVendorId(vendorId, showHidden: true); if (existingVendormanufacturers.FindVendorManufacturer(vendorId, manufacturerId) == null) { var vendorManufacturer = new VendorManufacturer { VendorId = vendorId, ManufacturerId = manufacturerId, DiscountPercentage = model.DiscountPercentage }; //a vendor cannot edit "IsFeaturedProduct" property //if (_workContext.CurrentVendor == null) //{ // productManufacturer.IsFeaturedProduct = model.IsFeaturedProduct; //} _manufacturerService.InsertVendorManufacturer(vendorManufacturer); } return(new NullJsonResult()); }