/// <summary>
        /// 搜索歌曲
        /// </summary>
        /// <param name="key"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private PageResult SearchSong(string[] keys, int page, int size)
        {
            var pagedList = _ctx.Music.Include(m => m.Singer)
                            .Where(m => keys.Any(k => m.Name.Contains(k) || m.Singer.Name.Contains(k)) && !m.IsDeleted && m.IsPublished)
                            .OrderByDescending(m => m.PublishmentTime)
                            .Select(m => new MusicContract()
            {
                Id       = m.Id,
                SingerId = m.SingerId,
                AlbumId  = m.AlbumId,
                Name     = m.Name,
                Duration = m.Duration,
                FileUrl  = m.FileUrl
            }).ToPagedList(page, size);
            var result = new MusicSearchPageResult()
            {
                PageNumber = pagedList.PageNumber,
                PageCount  = pagedList.PageCount,
                Results    = pagedList.Select(p =>
                {
                    p.SingerName = _ctx.Singer.SingleOrDefault(s => s.Id == p.SingerId && s.IsPublished && !s.IsDeleted)?.Name;
                    p.AlbumName  = _ctx.Album.SingleOrDefault(s => s.Id == p.AlbumId && s.IsPublished && !s.IsDeleted)?.Name;
                    return(p);
                }),
                ResultType = MusicRequestType.Song
            };

            return(result);
        }
Exemple #2
0
 private void PageLoadedUtil_MusicListPageLoadedEvent(object sender, EventArgs e)
 {
     if (IsVisible)
     {
         if (App.User != null)
         {
             var musicInfoOfPageModel = new MusicSearchPageResult()
             {
                 PageCount  = 1,
                 PageNumber = 1,
                 ResultType = MusicRequestType.Song,
                 Results    = _musicService.GetMusicsByMusicListId(_userMusicListId).Reverse()
             };
             SongCount.Text = (musicInfoOfPageModel?.Results.Count() ?? 0).ToString();
             MusicSearchInfoChangedUtil.InvokeFromJMSearchChanged(musicInfoOfPageModel, 1);
         }
     }
 }