Esempio n. 1
0
        public static int deleteSongEntry(MyPianoSong pianoSong)
        {
            if (pianoSong.songID <= 0)
            {
                throw new Exception("Unable to delete song, no song ID provided");
            }
            try
            {
                var newQuery = (from p in context.PianoSongs
                                where p.PianoSongID == pianoSong.songID
                                select p);
                PianoSong ps = newQuery.FirstOrDefault();
                Song      s  = ps.Song;
                Artist    a  = ps.Artist;
                Book      b  = ps.Book;
                context.PianoSongs.Remove(ps);
                context.SaveChanges();
                return(ps.PianoSongID);
            }
            catch (Exception ex)
            {
#if (DEBUG)
                Logger.LogError(ex, showDialog: true);
#else
                Logger.LogError(ex);
#endif
                return(-1);
            }
        }
Esempio n. 2
0
 public static int addSongEntry(MyPianoSong pianoSong)
 {
     try
     {
         Song      s     = new Song();
         Artist    a     = new Artist();
         Book      b     = new Book();
         PianoSong pSong = new PianoSong();
         s.SongName       = pianoSong.SongTitle;
         a.ArtistName     = pianoSong.SongArtist;
         b.BookName       = pianoSong.SongBook;
         pSong.Song       = s;
         pSong.Artist     = a;
         pSong.Book       = b;
         pSong.PageNumber = pianoSong.PageNum;
         context.PianoSongs.Add(pSong);
         context.SaveChanges();
         return(pSong.PianoSongID);
     }
     catch (Exception ex)
     {
         #if (DEBUG)
         Logger.LogError(ex, showDialog: true);
         #else
         Logger.LogError(ex);
         #endif
         return(-1);
     }
 }