partial void DeleteTag(Tag instance);
partial void UpdateTag(Tag instance);
partial void InsertTag(Tag instance);
private void detach_Tags(Tag entity) { this.SendPropertyChanging(); entity.Title = null; }
private void attach_Tags(Tag entity) { this.SendPropertyChanging(); entity.Title = this; }
public static void SetupCollectionsToBeAdded(OMLDataDataContext context, OMLEngine.Title title) { Title daoTitle = title.DaoTitle; // patch up the sort name if it's missing if (string.IsNullOrEmpty(daoTitle.SortName)) daoTitle.SortName = daoTitle.Name; // add the genres foreach (string genre in title.Genres) { // see if we've added this genre locally already Genre daoGenre = daoTitle.Genres.FirstOrDefault(t => t.MetaData.Name.Equals(genre)); // genres must be unique if (daoGenre != null) continue; // try to see if the genre exists GenreMetaData metaData = context.GenreMetaDatas.SingleOrDefault(t => t.Name.ToLower() == genre.ToLower()); if (metaData == null) { // if it doesn't exist create a new one metaData = new GenreMetaData(); metaData.Name = genre; context.GenreMetaDatas.InsertOnSubmit(metaData); context.SubmitChanges(); } // setup the genre daoGenre = new Genre(); daoGenre.MetaData = metaData; // add the genre to the title daoTitle.Genres.Add(daoGenre); } // add the tags foreach (string name in title.Tags) { // see if we've added this tag locally already Tag tag = daoTitle.Tags.FirstOrDefault(t => t.Name.Equals(name)); // tags must be unique if (tag != null) continue; // try to see if the tag exists in the db already //tag = context.Tags.SingleOrDefault(t => t.Name.ToLower() == name.ToLower()); if (tag == null) { // if it doesn't exist create a new one tag = new Tag(); tag.Name = name; } // add the tag daoTitle.Tags.Add(tag); } // grab from the db who we know about already Dictionary<string, BioData> existingPeople = GetAllExistingPeople(context, title); int actorIndex = 0; // add the actors foreach (Role actor in title.DaoTitle.UpdatedActors) { Person person = CreatePerson(context, actor.PersonName, actor.RoleName, PeopleRole.Actor, existingPeople); // maintain the order person.Sort = (short)(actorIndex++); // add them to the title daoTitle.People.Add(person); } // add the directors foreach (OMLEngine.Person director in title.DaoTitle.UpdatedDirectors) { Person person = CreatePerson(context, director.full_name, null, PeopleRole.Director, existingPeople); // maintain the order person.Sort = (short)(actorIndex++); // add them to the title var e = (from p in daoTitle.People where p.MetaData.Id == person.MetaData.Id select p); if (e.Count() == 0) { daoTitle.People.Add(person); } } // add the writers foreach (OMLEngine.Person writer in title.DaoTitle.UpdatedWriters) { Person person = CreatePerson(context, writer.full_name, null, PeopleRole.Writer, existingPeople); // maintain the order person.Sort = (short)(actorIndex++); // add them to the title daoTitle.People.Add(person); } // add the producers foreach (OMLEngine.Person name in title.DaoTitle.UpdatedProducers) { Person person = CreatePerson(context, name.full_name, null, PeopleRole.Producers, existingPeople); // maintain the order person.Sort = (short)(actorIndex++); // add them to the title daoTitle.People.Add(person); } // Debugging code var b = (from p in daoTitle.People select p); foreach (Person pr in b) { System.Diagnostics.Trace.WriteLine("Adding " + pr.Role + " - " + pr.MetaData.FullName + " as " + pr.CharacterName + " [" + pr.MetaData.Id +"]"); } // ignore the rest for now // add all the disks /*foreach (OMLEngine.Disk disk in title.Disks) { Disk daoDisk = new Disk(); daoDisk.Name = disk.Name; daoDisk.Path = disk.Path; daoDisk.VideoFormat = (byte)disk.Format; daoTitle.Disks.Add(daoDisk); } // add the audio tracks daoTitle.AudioTracks = GetDelimitedStringFromCollection(title.AudioTracks); // add the subtitles daoTitle.Subtitles = GetDelimitedStringFromCollection(title.Subtitles); // add the trailers daoTitle.Trailers = GetDelimitedStringFromCollection(title.Trailers);*/ }