Example #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());
     }
 }
Example #2
0
 public static tblUser AddUser(string username, string password)
 {
     try
     {
         using (dbPlayerEntities context = new dbPlayerEntities())
         {
             tblUser user = new tblUser();
             user.username = username;
             user.password = password;
             context.tblUsers.Add(user);
             context.SaveChanges();
             return(user);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
         return(null);
     }
 }
Example #3
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);
     }
 }