Exemplo n.º 1
0
 public static void DeleteSong(tblSong song)
 {
     try
     {
         using (dbPlayerEntities context = new dbPlayerEntities())
         {
             tblSong songToDelete = (from u in context.tblSongs where u.songId == song.songId select u).First();
             context.tblSongs.Remove(songToDelete);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
Exemplo n.º 2
0
 public static tblSong AddNewSong(tblSong song)
 {
     try
     {
         using (dbPlayerEntities context = new dbPlayerEntities())
         {
             tblSong newSong = new tblSong();
             newSong.author   = song.author;
             newSong.duration = song.duration;
             newSong.name     = song.name;
             newSong.userId   = song.userId;
             context.tblSongs.Add(newSong);
             context.SaveChanges();
             song.songId = newSong.songId;
             return(song);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
         return(null);
     }
 }