private static void UpdateArtist(IMyCollectionsData entity, IEnumerable <string> artistName) { if (entity.Artists != null && entity.Artists.Any()) { foreach (Artist artist in entity.Artists) { Dal.GetInstance.UnlinkArtist(artist, entity); } } if (artistName != null) { ArtistServices.AddArtists(artistName, entity); } else if (entity.Artists != null) { foreach (Artist artist in entity.Artists) { ArtistServices.SaveArtist(artist, entity); } } }
public static void Update(IMyCollectionsData entity) { try { LinksServices.DeleteLinks(entity); #region Publisher if (entity.Publisher != null) { if (String.IsNullOrWhiteSpace(entity.Publisher.Name) == false) { bool isNew; switch (entity.ObjectType) { case EntityType.Nds: case EntityType.Games: case EntityType.Books: case EntityType.Apps: entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "App_Editor"); if (isNew == true) { Dal.GetInstance.AddPublisher("App_Editor", entity.Publisher); } break; case EntityType.Series: case EntityType.Movie: entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "Movie_Studio"); if (isNew == true) { Dal.GetInstance.AddPublisher("Movie_Studio", entity.Publisher); } break; case EntityType.Music: entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "Music_Studio"); if (isNew == true) { Dal.GetInstance.AddPublisher("Music_Studio", entity.Publisher); } break; case EntityType.XXX: entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "XXX_Studio"); if (isNew == true) { Dal.GetInstance.AddPublisher("XXX_Studio", entity.Publisher); } break; } } } #endregion switch (entity.ObjectType) { case EntityType.Apps: Dal.GetInstance.AddApps(entity as Apps); break; case EntityType.Books: Dal.GetInstance.AddBook(entity as Books); break; case EntityType.Games: Dal.GetInstance.AddGame(entity as Gamez); break; case EntityType.Movie: Dal.GetInstance.AddMovie(entity as Movie); break; case EntityType.Music: if (MySettings.AutoUpdateID3 == true) { Task.Factory.StartNew(() => MusicServices.UpdateId3(entity as Music)); } Dal.GetInstance.AddMusic(entity as Music); Dal.GetInstance.AddTracks(entity as Music); break; case EntityType.Nds: Dal.GetInstance.AddNds(entity as Nds); break; case EntityType.Series: Dal.GetInstance.AddSeriesSeason(entity as SeriesSeason); break; case EntityType.XXX: Dal.GetInstance.AddXxx(entity as XXX); break; } #region Links LinksServices.AddLinks(entity.Links, entity, true); #endregion RessourcesServices.UpdateRessources(entity); #region Artist if (entity.Artists != null && entity.Artists.Any()) { foreach (Artist artist in entity.Artists) { Dal.GetInstance.UnlinkArtist(artist, entity); } } if (entity.Artists != null) { foreach (Artist artist in entity.Artists) { ArtistServices.SaveArtist(artist, entity); } } #endregion #region Genres Dal.GetInstance.UnlinkGenre(entity); GenreServices.AddGenres(entity.Genres, entity, true); #endregion } catch (Exception ex) { Util.LogException(ex); throw; } }