public BioData() { _bioData = new OMLEngine.Dao.BioData(); // Set a default date to stop exception (must change type from smalldate in db) _bioData.DateOfBirth = new DateTime(1900, 1, 1); }
private static void UpdatesImagesForBioData(Dao.BioData bd) { // if there's a new front cover image path if (bd.UpdatedImagePath != null) { // delete the old one if it exists if (bd.PhotoID != null) { Dao.TitleCollectionDao.SetDeleteImage((int)bd.PhotoID); } // add the new one bd.PhotoID = ImageManager.AddImageToDB(bd.UpdatedImagePath); // clear it out bd.UpdatedImagePath = null; } }
/// <summary> /// Creates a person object from a given name and role. Will check the db first to see if that person exists /// </summary> /// <param name="name"></param> /// <param name="role"></param> /// <returns></returns> public static Person CreatePerson(OMLDataDataContext context, string name, string characterName, PeopleRole role, Dictionary <string, BioData> existingPeople) { BioData metaData = null; // see if the actor exists already in the in memory cache existingPeople.TryGetValue(name, out metaData); if (metaData == null) { // Ok, we may not have allready created but first check if sql thinks it has // SQL thinks 'æ' and 'ae' are so lets double check the database metaData = Dao.TitleCollectionDao.GetPersonBioDataByName(context, name); } if (metaData == null) { System.Diagnostics.Trace.WriteLine("Adding Bio for - " + name); // if it doesn't exist create a new one metaData = new BioData(); metaData.FullName = name; context.BioDatas.InsertOnSubmit(metaData); context.SubmitChanges(); // add the new metaData we added to the dictionary so we don't add it again existingPeople.Add(name, metaData); } else { System.Diagnostics.Trace.WriteLine("Found Bio for - " + name + " : Fullname - " + metaData.FullName); } // setup the person Person person = new Person(); person.MetaData = metaData; person.Role = (byte)role; if (!string.IsNullOrEmpty(characterName)) { person.CharacterName = characterName; } return(person); }
/// <summary> /// Creates a person object from a given name and role. Will check the db first to see if that person exists /// </summary> /// <param name="name"></param> /// <param name="role"></param> /// <returns></returns> public static Person CreatePerson(OMLDataDataContext context, string name, string characterName, PeopleRole role, Dictionary<string, BioData> existingPeople) { BioData metaData = null; // see if the actor exists already in the in memory cache existingPeople.TryGetValue(name, out metaData); if (metaData == null) { // Ok, we may not have allready created but first check if sql thinks it has // SQL thinks 'æ' and 'ae' are so lets double check the database metaData = Dao.TitleCollectionDao.GetPersonBioDataByName(context, name); } if (metaData == null) { System.Diagnostics.Trace.WriteLine("Adding Bio for - " + name); // if it doesn't exist create a new one metaData = new BioData(); metaData.FullName = name; context.BioDatas.InsertOnSubmit(metaData); context.SubmitChanges(); // add the new metaData we added to the dictionary so we don't add it again existingPeople.Add(name, metaData); } else { System.Diagnostics.Trace.WriteLine("Found Bio for - " + name + " : Fullname - " + metaData.FullName); } // setup the person Person person = new Person(); person.MetaData = metaData; person.Role = (byte)role; if (!string.IsNullOrEmpty(characterName)) { person.CharacterName = characterName; } return person; }
public static void SaveBioMetaDataChanges() { System.Data.Linq.ChangeSet changeset = Dao.DBContext.Instance.GetChangeSet(); // Find actual SQL run to process the update - debugging purposes string s = Dao.DBContext.Instance.GetType().GetMethod("GetChangeText", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(Dao.DBContext.Instance, null) as string; // updates all the pending image changes foreach (object bio in changeset.Updates) { Dao.BioData daoBio = bio as Dao.BioData; if (daoBio != null) { UpdatesImagesForBioData(daoBio); } } Dao.DBContext.Instance.SubmitChanges(); }
partial void DeleteBioData(BioData instance);
partial void UpdateBioData(BioData instance);
partial void InsertBioData(BioData instance);
internal BioData(OMLEngine.Dao.BioData bioData) { _bioData = bioData; }