public static void Insert(AttributeGroup attributeGroup) { using (var db = OnlineStoreDbContext.Entity) { if (!db.Groups.Any(item => item.ParentID == attributeGroup.GroupID)) { db.AttributeGroups.Add(attributeGroup); db.SaveChanges(); } } }
public static void Update(AttributeGroup attributeGroup) { using (var db = OnlineStoreDbContext.Entity) { var orgAttributeGroup = db.AttributeGroups.Where(item => item.ID == attributeGroup.ID).Single(); orgAttributeGroup.GroupID = attributeGroup.GroupID; orgAttributeGroup.AttributeID = attributeGroup.AttributeID; orgAttributeGroup.LastUpdate = attributeGroup.LastUpdate; db.SaveChanges(); } }