Ejemplo n.º 1
0
        public tblSong AddSong(tblSong song)
        {
            try
            {
                using (AudioPlayerDataEntities context = new AudioPlayerDataEntities())
                {
                    tblSong newSong = new tblSong();

                    newSong.SongName   = song.SongName;
                    newSong.Author     = song.Author;
                    newSong.SongLength = song.SongLength;
                    newSong.UserID     = song.UserID;



                    context.tblSongs.Add(newSong);
                    context.SaveChanges();

                    return(newSong);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Ejemplo n.º 2
0
 public List <tblSong> GetSongsOfUser(int userid)
 {
     try
     {
         using (AudioPlayerDataEntities context = new AudioPlayerDataEntities())
         {
             List <tblSong> list = new List <tblSong>();
             list = (from x in context.tblSongs where x.UserID == userid select x).ToList();
             return(list);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
Ejemplo n.º 3
0
        public tblUser GetUserByUserName(string username)
        {
            try
            {
                using (AudioPlayerDataEntities context = new AudioPlayerDataEntities())
                {
                    tblUser user = (from x in context.tblUsers
                                    where x.UserName == username
                                    select x).First();

                    return(user);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Ejemplo n.º 4
0
        public void DeleteSong(int songId)
        {
            try
            {
                using (AudioPlayerDataEntities context = new AudioPlayerDataEntities())
                {
                    tblSong songToDelete = (from u in context.tblSongs
                                            where u.SongID == songId select u).First();


                    context.tblSongs.Remove(songToDelete);



                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
            }
        }
Ejemplo n.º 5
0
        public tblUser AddUser(tblUser user)
        {
            try
            {
                using (AudioPlayerDataEntities context = new AudioPlayerDataEntities())
                {
                    tblUser newUser = new tblUser();

                    newUser.UserName     = user.UserName;
                    newUser.UserPassword = user.UserPassword;


                    context.tblUsers.Add(newUser);
                    context.SaveChanges();

                    return(newUser);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }