public void InitLoginInfo(User user) { try { IsLogin = true; this.user = user; //defaultlist HistoryMusicList.User_Id = user.User_Id; HistoryMusicList = mDB.GetMusicList(HistoryMusicList); LikedMusicList.User_Id = user.User_Id; LikedMusicList = mDB.GetMusicList(LikedMusicList); //createdlist AllMusicLists = mDB.GetAllMusicList(user); for (int i = 0; i < AllMusicLists.Count(); i++) { if (DefaultList.Contains(AllMusicLists[i].ListName)) { continue; } CreatedMusicList.Add(mDB.GetMusicList(AllMusicLists[i]).ListName, i); } } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); } }
/// <summary> /// 创建自定义歌单 /// </summary> /// <param name="musicList"></param> /// <returns></returns> public bool CreateMusicList(MusicList musicList) { try { int n = 0; if (GetCreatedMusicListNumber() < ListLimits) { n = mDB.CreateMusicList(musicList); int i = AllMusicLists.Count(); AllMusicLists.Add(musicList); CreatedMusicList.Add(musicList.ListName, i); } return(n >= 0); } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); return(false); } }
/// <summary> /// 修改数据库中歌单名 /// </summary> /// <param name="musicList"></param> /// <param name="ListName"></param> public bool UpdateMusicList(MusicList musicList, string ListName) { try { if (musicList != null) { int index = CreatedMusicList[musicList.ListName]; CreatedMusicList.Remove(musicList.ListName); int n = mDB.UpdateMusicList(musicList, ListName); musicList.ListName = ListName; AllMusicLists[index].ListName = ListName; CreatedMusicList.Add(musicList.ListName, index); return(n >= 0); } return(false); } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); return(false); } }