internal static void AddParent(int id, int parent) { try { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); // Make sure there isn't already a listing for this ContentNesting exists = db.ContentNestings.Where(x => x.pageID.Equals(id) && x.parentID.Equals(parent)).FirstOrDefault<ContentNesting>(); if (exists != null && exists.ID > 0) { throw new Exception("Relationship exists."); } ContentNesting nest = new ContentNesting { pageID = id, parentID = parent }; db.ContentNestings.InsertOnSubmit(nest); db.SubmitChanges(); } catch (Exception) { } }
internal static void RemoveParent(int id, int parent) { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); ContentNesting nesting = new ContentNesting(); nesting = db.ContentNestings.Where(x => x.parentID.Equals(parent) && x.pageID.Equals(id)).FirstOrDefault<ContentNesting>(); db.ContentNestings.DeleteOnSubmit(nesting); db.SubmitChanges(); }