Example #1
0
        public static bool UpdatePlaylistSong(PlaylistSong editedPlaylistSong)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    PlaylistSong playlistSong = db.PlaylistSongs.Where(p => p.PlaylistID.Equals(editedPlaylistSong.PlaylistID) &&
                                                                       p.SongID.Equals(editedPlaylistSong.SongID)).First();
                    playlistSong.SongOrder = editedPlaylistSong.SongOrder;
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdatePlaylistSong", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdatePlaylistSong");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #2
0
        public static bool DeleteAlbum(Album albumToDelete)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Album alb = db.Albums.Where(a => a.AlbumID.Equals(albumToDelete.AlbumID)).First();

                    db.Albums.Remove(alb);
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.DeleteAlbum", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.DeleteAlbums");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #3
0
        public static bool AddAlbum(Album newAlbum)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    db.Albums.Add(newAlbum);
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.AddAlbum", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.AddAlbum");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #4
0
        public static bool DeletePlaylistSong(PlaylistSong playlistSongToDelete)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    db.PlaylistSongs.Remove(playlistSongToDelete);
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.DeletePlaylistSong", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.DeletePlaylistSong");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #5
0
        public static bool UpdateSong(Song editedSong)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Song son = db.Songs.Where(s => s.SongID.Equals(editedSong.SongID)).First();
                    son.SongTitle     = editedSong.SongTitle;
                    son.AlbumID       = editedSong.AlbumID;
                    son.ArtistID      = editedSong.ArtistID;
                    son.GenreID       = editedSong.GenreID;
                    son.PlaylistSongs = editedSong.PlaylistSongs;
                    son.Rating        = editedSong.Rating;
                    son.TrackLength   = editedSong.TrackLength;
                    son.TrackNumber   = editedSong.TrackNumber;
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdateSong", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdateSong");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #6
0
        public static bool UpdatePlaylist(Playlist editedPlaylist)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Playlist play = db.Playlists.Where(p => p.PlaylistID.Equals(editedPlaylist.PlaylistID)).First();
                    play.PlaylistName = editedPlaylist.PlaylistName;
                    //TODO: Need to think about this process some more.
                    //play.PlaylistSongs = editedPlaylist.PlaylistSongs;
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdatePlaylist", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdatePlaylist");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #7
0
        public static bool UpdateGenre(Genre editedGenre)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Genre gen = db.Genres.Where(g => g.GenreID.Equals(editedGenre.GenreID)).First();
                    gen.GenreName = editedGenre.GenreName;
                    //gen.Songs = editedGenre.Songs; //This seems unnecessary?
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdateGenre", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdateGenre");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #8
0
        public static bool UpdateArtist(Artist editedArtist)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Artist art = db.Artists.Where(a => a.ArtistID.Equals(editedArtist.ArtistID)).First();

                    art.ArtistName = editedArtist.ArtistName;
                    //art.Albums = editedArtist.Albums; //This seems unnecessary
                    //art.Songs = editedArtist.Songs; //This, too.
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdateArtist", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdateArtist");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }
Example #9
0
        public static bool UpdateAlbum(Album editedAlbum)
        {
            bool success = false;

            using (CDCatalogEntities db = new CDCatalogEntities())
            {
                try
                {
                    Album alb = db.Albums.Where(a => a.AlbumID.Equals(editedAlbum.AlbumID)).First();
                    alb.AlbumTitle = editedAlbum.AlbumTitle;
                    alb.Rating     = editedAlbum.Rating;
                    alb.Year       = editedAlbum.Year;
                    alb.ArtistID   = editedAlbum.ArtistID;
                    db.SaveChanges();
                    success = true;
                }
                catch (Exception SQLe)
                {
                    LogError("CDCatalogManager.UpdateAlbum", SQLe.ToString());
                    //using (StreamWriter sw = File.AppendText("errorlog.txt"))
                    //{
                    //    sw.WriteLine("--------------");
                    //    sw.WriteLine(DateTime.Now);
                    //    sw.WriteLine("Source: CDCatalogManager.UpdateAlbum");
                    //    sw.WriteLine(SQLe.ToString());
                    //}
                }
                return(success);
            }
        }