public static void DeletePointDocConnection(int id) { PointDocConnection connection = databaseContext.PointDocConnections.Where(a => a.id == id).First(); databaseContext.Entry(connection).State = System.Data.Entity.EntityState.Deleted; databaseContext.SaveChanges(); databaseContext = new PointDocumentationEntities(); }
//==============POINT DOC CONNECTION============== public static void CreatePointDocConnection(int pointID, int docID) { PointDocConnection connection = new PointDocConnection(pointID, docID); databaseContext.PointDocConnections.Add(connection); databaseContext.SaveChanges(); databaseContext = new PointDocumentationEntities(); }
public static void ChangeDocPointConnection(int docID, HashSet <int> pointsID) { foreach (var pointID in pointsID) { PointDocConnection connection = databaseContext.PointDocConnections.Where(a => a.DocumentID == docID && a.PointID == pointID).FirstOrDefault(); if (connection == null) { connection = new PointDocConnection(pointID, docID); databaseContext.PointDocConnections.Add(connection); } else { databaseContext.Entry(connection).State = System.Data.Entity.EntityState.Deleted; } } databaseContext.SaveChanges(); databaseContext = new PointDocumentationEntities(); }