/// <summary> /// Adding new archive into database. /// </summary> /// <param name="newArchive">New archive entity.</param> /// <returns>ID for created archive.</returns> public int AddArchive(Archive newArchive) { using (PhotoCollectionDatabaseEntities context = new PhotoCollectionDatabaseEntities(_connectionString)) { newArchive.ID = context.Tags.NextId(p => p.ID); context.Archives.AddObject(newArchive); context.SaveChanges(); return newArchive.ID; } }
/// <summary> /// Adds the template archive. /// </summary> /// <returns>Sample archive ID.</returns> public int AddTemplateArchive() { using (PhotoCollectionDatabaseEntities context = new PhotoCollectionDatabaseEntities(_connectionString)) { Archive archive = new Archive(); archive.ID = context.Archives.NextId(a => a.ID); archive.Capacity = 1048567; archive.IsExternal = false; archive.DeviceID = "007"; archive.HddLetter = "C"; context.Archives.AddObject(archive); context.SaveChanges(); return archive.ID; } }
private void FixupArchive(Archive previousValue, bool skipKeys = false) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.Photos.Contains(this)) { previousValue.Photos.Remove(this); } if (Archive != null) { if (!Archive.Photos.Contains(this)) { Archive.Photos.Add(this); } SourceID = Archive.ID; } else if (!skipKeys) { SourceID = null; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Archive") && (ChangeTracker.OriginalValues["Archive"] == Archive)) { ChangeTracker.OriginalValues.Remove("Archive"); } else { ChangeTracker.RecordOriginalValue("Archive", previousValue); } if (Archive != null && !Archive.ChangeTracker.ChangeTrackingEnabled) { Archive.StartTracking(); } } }