private Album CreateAlbum(string albumName, int albumYear) { var album = new Album(albumName, albumYear); _albums.Add(album); return(album); }
public static IList <AlbumGroup> ToAlbumGroups(this SoundCloudClone.Models.Api.Home home) { var albumGroups = new List <AlbumGroup>(); foreach (var algumGroupsCollection in home.AlgumGroupsCollection) { var albumGroupApi = algumGroupsCollection.AlbumGroup; var albumGroupApp = new AlbumGroup( albumGroupApi.Title, albumGroupApi.Description ); var albumCollection = new AlbumCollection(); foreach (var albumsApi in algumGroupsCollection.AlbumGroup.AlbumCollection.Albums) { albumCollection.Add( new Album( albumsApi.ArtworkUrlTemplate, albumsApi.ArtworkStyle, albumsApi.Count, albumsApi.ShortTitle, albumsApi.ShortSubtitle ) ); } albumGroupApp.Add(albumCollection); albumGroups.Add(albumGroupApp); } return(albumGroups); }
/// <summary> /// Recursively walk the JRMC tree of items and files to find all music tracks, music albums and photo albums /// </summary> /// <param name="itemiD"></param> /// <param name="albumList"></param> /// <param name="photoAlbumList"></param> static void FetchAllAlbums(string itemiD, AlbumCollection albumList, AlbumCollection photoAlbumList) { var childIds = GetChildren(itemiD); // If there are child items, recursively walk the tree if (childIds != null && childIds.Count != 0) { if (Convert.ToInt32(itemiD) >= 1000) { foreach (var childName in childIds.Keys) { var childId = childIds[childName]; FetchAllAlbums(childId, albumList, photoAlbumList); } } else { if (childIds.ContainsKey("Artist")) { FetchAllAlbums(childIds["Artist"], albumList, photoAlbumList); } if (childIds.ContainsKey("Album")) { FetchAllAlbums(childIds["Album"], albumList, photoAlbumList); } if (childIds.ContainsKey("Composer")) { FetchAllAlbums(childIds["Composer"], albumList, photoAlbumList); } } } else { // If there are NO child items, the files are music tracks or photos var tracks = GetTracks(itemiD); if (tracks != null && tracks.Length != 0) { string albumId = tracks[0].Info["Key"]; if (tracks[0].Info["Filename"].Contains(@"\Photos\")) { if (!photoAlbumList.Keys.Contains(albumId)) { var album = new AlbumData(albumId, tracks); photoAlbumList.Add(albumId, album); } } else { if (!albumList.Keys.Contains(albumId)) { var album = new AlbumData(albumId, tracks); albumList.Add(albumId, album); } } } } }
/// <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; }
public async Task LoadAlbums() { // AlbumCollection.IsObserving = true; //AlbumCollection.AddRange(); foreach (var album in await GetAlbums().ConfigureAwait(false)) { AlbumCollection.Add(album); } }
public static AlbumCollection SelectAll(SqlConnection con) { var List = new AlbumCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "sp_tblAlbum_Select_SelectAll_linhnx")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
private AlbumViewModel LookupAlbum(AlbumModel album) { if (AlbumLookupMap.ContainsKey(album.AlbumId)) { return(AlbumLookupMap[album.AlbumId]); } else { ArtistViewModel artist = LookupArtistById(album.ArtistId); AlbumViewModel newAlbumViewModel = new AlbumViewModel(album, artist); AlbumLookupMap.Add(newAlbumViewModel.AlbumId, newAlbumViewModel); AlbumCollection.Add(newAlbumViewModel, newAlbumViewModel.SortName); return(newAlbumViewModel); } }
private void Timer_Tick(object sender, EventArgs e) { if (AlbumCollection.Count >= 5000) { Stop(); } var newAlbum = new Album { Title = SampleData.Albums.ElementAt(random.Next(0, SampleData.Albums.Count - 1)).Title, Genre = SampleData.Genres.ElementAt(random.Next(0, SampleData.Genres.Count - 1)), Price = (decimal)random.NextDouble() * random.Next(1, 100), Artist = SampleData.Artists.ElementAt(random.Next(0, SampleData.Artists.Count - 1)), AlbumArtUrl = "/Content/Images/placeholder.gif" }; Action action = () => { AlbumCollection.Add(newAlbum); }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(action)); }
public static AlbumCollection SelectByPid(SqlConnection con, string PID) { var List = new AlbumCollection(); var obj = new SqlParameter[1]; if (!string.IsNullOrEmpty(PID)) { obj[0] = new SqlParameter("PID", PID); } else { obj[0] = new SqlParameter("PID", DBNull.Value); } using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "sp_tblAlbum_Select_SelectByPid_linhnx", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
internal void AlertAlbumNameChanged(AlbumViewModel albumViewModel, string oldName) { AlbumCollection.Remove(albumViewModel, oldName); AlbumCollection.Add(albumViewModel, albumViewModel.SortName); }