public bool UpdateCategoriesToProduct(List<Guid> categoriesIds, Guid productId) { lock (obj) { BL.Modules.Products.Products pbl = new BL.Modules.Products.Products(); pbl.DeleteProductCategories(productId); return AddCategoriesToProduct(categoriesIds, productId); } }
public bool AddCategoriesToProduct(List<Guid> categoriesIds, Guid productId) { bool add = true; BL.Modules.Products.Products pbl = new BL.Modules.Products.Products(); ShopDataContext db = new ShopDataContext(); foreach (Guid item in categoriesIds) { BL.ProductsRefCategory prod = db.ProductsRefCategories.Where(c => c.CategoryID == item && c.ProductID == productId).FirstOrDefault(); if (prod == null) { add = pbl.AddCategoryToProduct(item, productId, db); } } return add; }