/// <summary> /// Add a new artist to the storage and the local collections /// </summary> /// <param name="artistToAdd"></param> public static async Task AddArtistAsync(Artist artistToAdd) { // Need to wait for the Artist to be added so that its Id is available await DbAccess.InsertAsync(artistToAdd); ArtistCollection.Add(artistToAdd); IdLookup[artistToAdd.Id] = artistToAdd; }
/// <summary> /// Add a new album to the storage and the local collections /// </summary> /// <param name="albumToAdd"></param> public static async Task AddAlbumAsync(Album albumToAdd) { AlbumCollection.Add(albumToAdd); // Need to wait for the Album to be added to ensure that its ID is available await DbAccess.InsertAsync(albumToAdd); IdLookup[albumToAdd.Id] = albumToAdd; }
/// <summary> /// Add a new ArtistAlbum to the storage and the local collections /// </summary> /// <param name="artistAlbumToAdd"></param> public static async Task AddArtistAlbumAsync(ArtistAlbum artistAlbumToAdd) { ArtistAlbumCollection.Add(artistAlbumToAdd); // Need to wait for the ArtistAlbum to be added as that will set its ID await DbAccess.InsertAsync(artistAlbumToAdd); IdLookup[artistAlbumToAdd.Id] = artistAlbumToAdd; }
/// <summary> /// Add a new library to the collection and to persistent storage /// </summary> /// <param name="newLibrary"></param> public static async Task AddLibraryAsync(Library newLibrary) { LibraryCollection.Add(newLibrary); // Need to wait for the Library to be added to ensure that its ID is available await DbAccess.InsertAsync(newLibrary); // Reform the library names collection LibraryNames = LibraryCollection.Select(lib => lib.Name).ToList(); }
/// <summary> /// Add a new source to the collection and to persistent storage /// </summary> /// <param name="sourceToAdd"></param> /// <returns></returns> public static async Task AddSourceAsync(Source sourceToAdd) { SourceCollection.Add(sourceToAdd); // Need to wait for the source to be added to ensure that its ID is available await DbAccess.InsertAsync(sourceToAdd); // Initialise any source data that may not have been set in the new source sourceToAdd.InitialiseAccess(); }
/// <summary> /// Create a GenrePopulation and add it to the collection. /// </summary> /// <param name="population"></param> public static GenrePopulation CreatePopulation(int autoplayId, int index, IEnumerable <string> genres) { GenrePopulation newPopulation = new() { AutoplayId = autoplayId, Index = index, GenreString = string.Join(";", genres) }; GenrePopulationCollection.Add(newPopulation); // No need to wait for this DbAccess.InsertAsync(newPopulation); return(newPopulation); }
/// <summary> /// Add the specified Song to the local collections and persistent storage /// </summary> /// <param name="songToAdd"></param> public static async void AddSongAsync(Song songToAdd) { // Must wait for this to get the song id await DbAccess.InsertAsync(songToAdd); lock ( lockObject ) { SongCollection.Add(songToAdd); IdLookup.Add(songToAdd.Id, songToAdd); artistAlbumLookup.AddValue(songToAdd.ArtistAlbumId, songToAdd); albumLookup.AddValue(songToAdd.AlbumId, songToAdd); } }
/// <summary> /// Add a new tag to the storage and the local collections /// </summary> /// <param name="albumToAdd"></param> public static async void AddTagAsync(Tag tagToAdd) { TagsCollection.Add(tagToAdd); if (tagToAdd.PersistTag == true) { // We need to wait for this in case the caller want to use the Tag Id await DbAccess.InsertAsync(tagToAdd); } NameLookup[tagToAdd.Name] = tagToAdd; ShortNameLookup[tagToAdd.ShortName] = tagToAdd; }
/// <summary> /// Get the Autoplay record associated with the specified library. /// If there is no such record then create one /// </summary> /// <param name="libraryId"></param> /// <returns></returns> public static async Task <Autoplay> GetAutoplayAsync(int libraryId) { Autoplay autoPlay = AutoplayCollection.SingleOrDefault(auto => auto.LibraryId == libraryId); if (autoPlay == null) { autoPlay = new Autoplay() { LibraryId = libraryId }; // Need to wait for thus so that it's Id gets set await DbAccess.InsertAsync(autoPlay); } return(autoPlay); }
/// <summary> /// Add a new TaggedAlbum to the storage and the local collections /// </summary> /// <param name="artistAlbumToAdd"></param> public static void AddTaggedAlbum(TaggedAlbum taggedAlbumToAdd) { // No need to wait for the TaggedAlbum to be added to storage DbAccess.InsertAsync(taggedAlbumToAdd); TaggedAlbumCollection.Add(taggedAlbumToAdd); }
/// <summary> /// Add a playlist to the local and storage collections. /// Wait for the storage to complete in case the called requires access to the stored Id /// </summary> /// <param name="playlistToAdd"></param> public static async Task AddPlaylistAsync(Playlist playlistToAdd) { PlaylistCollection.Add(playlistToAdd); await DbAccess.InsertAsync(playlistToAdd); }