Example #1
0
        protected override async void SetById(long id)
        {
            var task1 = _netWorkServices.GetAsync <Artist>("Artist", "GetArtistDetailById", new { id });
            var task2 = _netWorkServices.GetAsync <KeyValuePair <bool, List <Global.Model.Album> > >("Artist", "GetArtistAlbum", new { id, offset = 0, limit = RequireCountPerPage });
            var task3 = _netWorkServices.GetAsync <KeyValuePair <bool, List <Global.Model.Mv> > >("Artist", "GetArtistMv", new { id, offset = 0, limit = RequireCountPerPage });
            var task4 = _netWorkServices.GetAsync <List <KeyValuePair <string, string> > >("Artist", "GetArtistIntroduction", new
            {
                id
            });
            var task5 = _netWorkServices.GetAsync <List <Global.Model.Artist> >("Artist", "GetSimiArtists", new { id });
            //  KeyValuePair<bool, List<Global.Model.Album>>
            await Task.WhenAll(task1, task2, task3, task4, task5);

            if (task1.Result.Successed &&
                task2.Result.Successed &&
                task3.Result.Successed &&
                task4.Result.Successed &&
                task5.Result.Successed)
            {
                _innerArtist = task1.Result.Data;
                var moreAndAlbums = task2.Result.Data;
                MoreAlbums = moreAndAlbums.Key;
                var moreAndMvs = task3.Result.Data;
                MoreMvs = moreAndMvs.Key;
                await Task.WhenAll(HotMusics.AddRangeAsync(_innerArtist.HotMusics),
                                   Albums.AddRangeAsync(moreAndAlbums.Value),
                                   Mvs.AddRangeAsync(moreAndMvs.Value),
                                   ArtistIntroductions.AddRangeAsync(task4.Result.Data),
                                   SimiArtists.AddRangeAsync(task5.Result.Data));

                RaiseAllPropertyChanged();
            }
        }