コード例 #1
0
ファイル: TitleDao.cs プロジェクト: peeboo/open-media-library
        /// <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;
        }
コード例 #2
0
 partial void DeletePerson(Person instance);
コード例 #3
0
 partial void UpdatePerson(Person instance);
コード例 #4
0
 partial void InsertPerson(Person instance);
コード例 #5
0
		private void detach_Peoples(Person entity)
		{
			this.SendPropertyChanging();
			entity.Title = null;
		}
コード例 #6
0
		private void attach_Peoples(Person entity)
		{
			this.SendPropertyChanging();
			entity.Title = this;
		}