public async Task <IActionResult> LyricInfo(int?id, string title = null, string artist = null, string picurl = null)
        {
            if (id == null)
            {
                return(HttpBadRequest());
            }
            //编码
            SongResponseById detailedSong = new SongResponseById();
            WebSong          song         = new WebSong();
            await Task.Run(() =>
            {
                var task     = HttpReqProxy.GetSongByIdAsync(id.Value.ToString());
                detailedSong = task.GetAwaiter().GetResult();
                if (detailedSong.showapi_res_code == -1)
                {
                    throw new HttpRequestException(detailedSong.showapi_res_error);
                }
            });

            SongFileManager.SetSongById(song, detailedSong.showapi_res_body);
            song.Title        = title;
            song.Artist       = artist;
            song.Albumpic_big = picurl;
            return(View(song));
        }
        public async Task <IActionResult> Search(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return(View());
            }
            SongResponseByName resSongs = new SongResponseByName();
            await Task.Run(() =>
            {
                var task = HttpReqProxy.GetSongByNameAsync(content);
                resSongs = task.GetAwaiter().GetResult();
                // http请求返回错误
                if (resSongs.showapi_res_code == -1)
                {
                    throw new HttpRequestException(resSongs.showapi_res_error);
                }
            });

            SongFileManager.SetSongListByName(WebSongs, resSongs.showapi_res_body.pagebean.contentlist);
            ViewData["content"] = content;
            return(View(WebSongs));
        }
        //GET: BandList
        public async Task <IActionResult> BandList(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            SongResponseBandList resSongs1 = new SongResponseBandList();
            await Task.Run(() =>
            {
                var task1 = HttpReqProxy.GetBandListAsync(id.Value);
                resSongs1 = task1.GetAwaiter().GetResult();
                // http请求返回错误
                if (resSongs1.showapi_res_code == -1)
                {
                    throw new HttpRequestException(resSongs1.showapi_res_error);
                }
            });

            SongFileManager.SetSongListByBand(WebSongs, resSongs1.showapi_res_body.pagebean.songlist);

            ViewData["rankname"] = RankNameFromId(id.Value);
            return(View(WebSongs));
        }
Esempio n. 4
0
        public async Task <IActionResult> Index()
        {
            SongResponseBandList resSongs1 = new SongResponseBandList();
            SongResponseBandList resSongs2 = new SongResponseBandList();
            SongResponseBandList resSongs3 = new SongResponseBandList();
            await Task.Run(() =>
            {
                var task1 = HttpReqProxy.GetBandListAsync(5); //内地
                resSongs1 = task1.GetAwaiter().GetResult();
                // http请求返回错误
                if (resSongs1.showapi_res_code == -1)
                {
                    throw new HttpRequestException(resSongs1.showapi_res_error);
                }

                var task2 = HttpReqProxy.GetBandListAsync(5); //内地
                resSongs2 = task2.GetAwaiter().GetResult();
                // http请求返回错误
                if (resSongs2.showapi_res_code == -1)
                {
                    throw new HttpRequestException(resSongs2.showapi_res_error);
                }

                var task3 = HttpReqProxy.GetBandListAsync(5); //内地
                resSongs3 = task3.GetAwaiter().GetResult();
                // http请求返回错误
                if (resSongs3.showapi_res_code == -1)
                {
                    throw new HttpRequestException(resSongs3.showapi_res_error);
                }
            });

            SongFileManager.SetSongListByBand(homeSongDb.Band1List, resSongs1.showapi_res_body.pagebean.songlist);
            SongFileManager.SetSongListByBand(homeSongDb.Band2List, resSongs2.showapi_res_body.pagebean.songlist);
            SongFileManager.SetSongListByBand(homeSongDb.Band3List, resSongs3.showapi_res_body.pagebean.songlist);
            return(View(homeSongDb));
        }