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); } }
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); } }
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); } }
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()); } }
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); } }