コード例 #1
0
 /// <summary>
 /// Method for deleting song from database
 /// </summary>
 /// <param name="song"></param>
 /// <returns>true if deleted, false if not</returns>
 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);
     }
 }
コード例 #2
0
 /// <summary>
 /// Method for adding song by user
 /// </summary>
 /// <param name="user">user which is adding song</param>
 /// <param name="song">song for adding</param>
 /// <returns></returns>
 public bool AddSong(vwUser user, vwSong song)
 {
     try
     {
         using (AudioPlayerEntities context = new AudioPlayerEntities())
         {
             tblSong newSong = new tblSong();
             newSong.SongName     = song.SongName;
             newSong.SongAuthor   = song.SongAuthor;
             newSong.SongDuration = song.SongDuration;
             newSong.UserId       = user.UserId;
             context.tblSongs.Add(newSong);
             context.SaveChanges();
             song.SongId = newSong.SongId;
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
コード例 #3
0
 public bool AddSong(tblUser user, vwSong song)
 {
     try
     {
         using (DAN_LEntities context = new DAN_LEntities())
         {
             tblSong newSong = new tblSong();
             newSong.SongName = song.SongName;
             newSong.Author   = song.Author;
             newSong.Duration = song.Duration;
             newSong.UserID   = user.UserID;
             context.tblSongs.Add(newSong);
             context.SaveChanges();
             song.SongID = newSong.SongID;
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
コード例 #4
0
 public AddViewModel(AddView songView, vwUser user)
 {
     this.songView = songView;
     User          = user;
     Song          = new vwSong();
 }