Esempio n. 1
0
 public bool DeleteSong(vwSong song)
 {
     try
     {
         using (AudioPlayerEntities context = new AudioPlayerEntities())
         {
             var songToDelete = context.tblSongs.Where(x => x.SongId == song.SongId).FirstOrDefault();
             context.tblSongs.Remove(songToDelete);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
Esempio n. 2
0
 public bool CreateSong(vwUser user, vwSong song)
 {
     try
     {
         using (AudioPlayerEntities context = new AudioPlayerEntities())
         {
             tblSong newSong = new tblSong
             {
                 Author   = song.Author,
                 Duration = song.Duration,
                 Name     = song.Name,
                 UserId   = user.UserId
             };
             context.tblSongs.Add(newSong);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }