/// <summary> /// 添加到用户最近播放 /// </summary> /// <param name="id"></param> /// <param name="sid"></param> /// <returns></returns> internal static bool AddRecentSong(int id, int sid) { using (YoungMusicEntities db = new YoungMusicEntities()) { var u = db.UserInfo.FirstOrDefault(m => m.U_Id == id); if (u != null) { u.U_Like += sid.ToString() + ","; SongListService.AddCount(sid, 1); return(db.SaveChanges() > 0); } return(false); } }
/// <summary> /// 获取自己的动态 /// </summary> /// <param name="uid"></param> /// <param name="top"></param> /// <param name="page"></param> /// <returns></returns> internal static List <Dictionary <string, object> > GetMyDynamicInfo(int uid, int top, int page) { List <Dictionary <string, object> > result = new List <Dictionary <string, object> >(); using (YoungMusicEntities db = new YoungMusicEntities()) { var user = db.UserInfo.FirstOrDefault(x => x.U_Id == uid); if (user == null) { return(null); } var dyn = (from d in db.Dynamic join u in db.UserInfo on d.D_UserId equals u.U_Id select new { D_Id = d.D_Id, D_Title = d.D_Title, D_UserId = d.D_UserId, D_Content = d.D_Content, D_GoodCount = d.D_GoodCount, D_imgs = d.D_imgs, D_SongID = d.D_SongID, D_UpTime = d.D_UpTime, U_info = new { U_Id = u.U_Id, U_Img = u.U_Img, U_Info = u.U_Info, //U_Like = u.U_Like, U_Name = u.U_Name, //U_Email = u.U_Email, //U_Birthday = u.U_Birthday, //U_Tell = u.U_Tell, U_Fans = u.U_Fans, U_Follow = u.U_Follow, //U_Gender = u.U_Gender, //U_Hobby = u.U_Hobby, //U_RegistrationTime = u.U_RegistrationTime, //U_CollectSongMenu = u.U_CollectSongMenu, //U_CreatSongMenu = u.U_CreatSongMenu } }).Where(m => m.D_UserId == uid).ToList().OrderByDescending(m => m.D_UpTime).Skip(top * page).Take(top); foreach (var item in dyn) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Dynamic", item); if (item.D_SongID != null) { var song = SongListService.SelSongbyID((int)item.D_SongID); dic.Add("Song", song); } else { dic.Add("Song", null); } result.Add(dic); } return(result); } }