public bool UpdateAllPropertiesByCategoryId(IQueryable<BL.CategoryProperty> properties, Guid categoryId) { bool updateProperties = false; using (ShopDataContext db = new ShopDataContext()) { BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault(); if (category != null) { using (var ts = new TransactionScope()) { db.CategoryProperties.AttachAll(properties); db.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, properties); db.SubmitChanges(); ts.Complete(); updateProperties = true; } } } return updateProperties; }
public void UpdateCategoryName(Guid categoryId, string name) { using (var db = new ShopDataContext()) { BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault(); if (category != null) { category.Name = name; db.SubmitChanges(); } db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues); } }
public void UpdateCategory(Guid categoryId, string name, Guid? parentId) { using (ShopDataContext db = new ShopDataContext()) { BL.Category category = db.Categories.Where(c => c.CategoryID == categoryId).FirstOrDefault(); if (category != null) { using (var ts = new TransactionScope()) { category.Name = name; category.ParentID = parentId; db.SubmitChanges(); ts.Complete(); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues); } } } }
public void UpdateAllCategories(List<Guid> categories) { using (var db = new ShopDataContext()) { using (var ts = new TransactionScope()) { var index = 0; foreach (var item in categories) { var categ = db.Categories.First(c => c.CategoryID == item); categ.Sort = index; index++; } db.SubmitChanges(); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues); ts.Complete(); } } }
public bool UpdateProductPhotoProperty(string url, Guid propId) { bool allRight = false; using (ShopDataContext db = new ShopDataContext()) { BL.ProductProperty productProperty = db.ProductProperties.Where(p => p.PropertyID == propId).FirstOrDefault(); if (productProperty != null) { productProperty.PropertyValue = url; db.SubmitChanges(); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.ProductProperties); allRight = true; } } return allRight; }