Exemplo n.º 1
0
        /// <summary>
        /// Sync new Playlist with localDb and serverDb
        /// </summary>
        public void initializePlaylist()
        {
            PlaylistsNwManager.PostPlaylist(this);
            PlaylistsManager.db_Add_Update_Record(PlaylistsNwManager.GetPlaylists().FindLast(e => e.name == this.name));
            Playlist temp = PlaylistsManager.db_GetAllPlaylists().FindLast(e => e.name == this.name);

            this.id           = temp.id;
            this.resource_uri = temp.resource_uri;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sync Local DB with Server DB
        /// </summary>
        public static void SyncLocalDbWithServerDb()
        {
            // Delete all local tables
            AlbumsManager.db_Delete_All();
            ArtistsManager.db_Delete_All();
            PlaylistsManager.db_Delete_All();

            //Get all server tables
            List <Album>    albums    = AlbumsNwManager.GetAlbums();
            List <Artist>   artists   = ArtistsNwManager.GetArtists();
            List <Playlist> playlists = PlaylistsNwManager.GetPlaylists();
            List <Track>    tracks    = TracksNwManager.GetTracks();


            // < sync local tables with server tables >
            foreach (var item in albums)
            {
                AlbumsManager.db_Add_Update_Record(item);
            }
            foreach (var item in artists)
            {
                ArtistsManager.db_Add_Update_Record(item);
            }
            foreach (var item in playlists)
            {
                PlaylistsManager.db_Add_Update_Record(item);
            }
            foreach (var item in tracks)
            {
                TracksManager.db_Add_Update_Record(item);
            }
            // </ sync local tables with server tables >

            // < Add relations to local db >
            foreach (Album album in albums)
            {
                foreach (string artistId in album.artists)
                {
                    AlbumFromArtistManager.db_Add_Update_Record((int)album.id, Convert.ToInt32(artistId));
                }
            }

            foreach (Artist artist in artists)
            {
                foreach (string trackId in artist.songs)
                {
                    TrackFromArtistManager.db_Add_Update_Record(Convert.ToInt32(trackId), (int)artist.id);
                }
            }
            // </ Add relations to local db >
        }