protected override async void SetById(long id) { var innerMvdataResult = await this._netWorkServices.GetAsync <Mv>("Common", "GetMvById", new { id }); if (!innerMvdataResult.Successed) { //todo 网络连接四百 return; } _innerMv = innerMvdataResult.Data; var task1 = _netWorkServices.GetAsync <CommentCollection>("Common", "GetCommentById", new { commentThreadId = _innerMv.CommendThreadId }); var task2 = _netWorkServices.GetAsync <Mv[]>("Common", "GetSimiMv", new { id }); await Task.WhenAll(task1, task2); if (task1.Result.Successed && task2.Result.Successed) { _innerComment = task1.Result.Data; await Task.WhenAll( NewComments.AddRangeAsync(_innerComment.Comments), HotComments.AddRangeAsync(_innerComment.HotComments), SimiMvs.AddRangeAsync(task2.Result.Data)); this._currentPage = 1; RaiseAllPropertyChanged(); RefreshCompleated?.Invoke(this, EventArgs.Empty); } else { //todo 网络连接四百 } }
private async void ThumbsUpCommandExecute(long?obj) { if (obj > 0) { await this._netWorkServices.GetAsync <Dictionary <string, object> >("Common", "ThumbsUpComment", new { commentId = obj.Value, commentThreadId = Global.Enums.CommentType.R_SO_4_.ToString() + Id, thumbsUp = true }); var query = HotComments.Select((x, i) => new { Model = x, Index = i }) .FirstOrDefault(x => x.Model.CommentId == obj); if (query != null) { query.Model.LikedCount++; HotComments.RemoveAt(query.Index); HotComments.Insert(query.Index, query.Model); return; } query = NewComments.Select((x, i) => new { Model = x, Index = i }) .FirstOrDefault(x => x.Model.CommentId == obj); if (query != null) { query.Model.LikedCount++; NewComments.RemoveAt(query.Index); NewComments.Insert(query.Index, query.Model); } } }
protected override async void SetById(long id) { var task1 = this._netWorkServices.GetAsync <Music>("Music", "GetMusicDetailById", new { id }); var task2 = this._netWorkServices.GetAsync <List <Music> >("Music", "GetSimiMusic", new { id }); var task3 = this._netWorkServices.GetAsync <CommentCollection>("Common", "GetCommentById", new { commentThreadId = $"R_SO_4_{id}" }); var task4 = this._netWorkServices.GetAsync <List <Lyric> >("Music", "GetLyricByMusicId", new { id }); var task5 = this._netWorkServices.GetAsync <PlayList[]>("Music", "GetSimiPlayList", new { id }); await Task.WhenAll(task1, task2, task3, task4, task5); if (task1.Result.Successed && task2.Result.Successed && task3.Result.Successed && task4.Result.Successed && task5.Result.Successed) { this._innerMusic = task1.Result.Data; this._innerComment = task3.Result.Data; await Task.WhenAll( Artists.AddRangeAsync(this._innerMusic.Artists), SimiMusics.AddRangeAsync(task2.Result.Data), NewComments.AddRangeAsync(this._innerComment.Comments), HotComments.AddRangeAsync(this._innerComment.HotComments), Lryics.AddRangeAsync(task4.Result.Data), ContainsThisTrackList.AddRangeAsync(task5.Result.Data)); this._currentPage = 1; RaiseAllPropertyChanged(); } else { //todo 提示信息 } }
public async Task RefreshCommentsCollection(string id) { foreach (var model in await CommonDataLoader.GetGeneralModelsCollectionByUriAsync <CommentModel>(string.Format(ServicesUrl.MovieComment, Id))) { if (model.Type == "0") { HotComments.Add(model); } else { NormalComments.Add(model); } } }
public async Task RefreshCommentsCollection(string uri) { foreach (var item in await DataHelper.GetCommentJsonArrayAsync(uri)) { var tem = JsonConvert.DeserializeObject <CommentModel>(item.Stringify()); if (tem.Type == "0") { HotComments.Add(tem); } else { NormalComments.Add(tem); } } }
private async void OnCurrentPageChanged() { var temp = await _netWorkServices.GetAsync <CommentCollection>("Common", "GetCommentById", new { commentThreadId = _innerMv.CommendThreadId, offset = (CurrentPage - 1) * Settings.Default.LimitPerPage, limit = Settings.Default.LimitPerPage }); if (temp.Successed) { _innerComment = temp.Data; await Task.WhenAll( NewComments.AddRangeAsync(_innerComment.Comments), HotComments.AddRangeAsync(_innerComment.HotComments) ); } }
/// <summary> /// 加载热门评论 /// </summary> /// <param name="count"></param> /// <param name="timeStamp"></param> /// <returns></returns> private async Task <IEnumerable <Comment> > LoadHotComments(uint count, string timeStamp) { if (timeStamp.Equals(hotCommentsStringBuilder.ToString()) || timeStamp.Equals("0")) { HotComments.NoMore(); return(null); } var result = await ApiService.Instance.GetLatestOrHotCommentsAsync(DocumentId, CommentTypeEnum.hot, timeStamp); if (result != null && result.Comments != null) { if (!string.IsNullOrEmpty(timeStamp)) { hotCommentsStringBuilder.Clear(); hotCommentsStringBuilder.Append(timeStamp); } HotComments.TimeStamp = result.TimeStamp; if (result.Comments.Count == 0 && HotComments.Count == 0) { IsHotCommentsEmpty = true; } return(result.Comments); } else { HotComments.NoMore(); if (HotComments.Count == 0) { IsHotCommentsEmpty = true; } else { IsHotCommentsEmpty = false; } } return(null); }
/// <summary> /// 当当前页发生变化的时候,刷新 /// </summary> private async void OnCurrentPageChanged() { if (this._innerComment.More) { var ccDataResult = await this._netWorkServices.GetAsync <CommentCollection>("Common", "GetCommentById", new { commentThreadId = $"R_SO_4_{Id}", offset = ((int)CurrentPage - 1) * Settings.Default.LimitPerPage, limit = Settings.Default.LimitPerPage }); if (ccDataResult.Successed) { this._innerComment = ccDataResult.Data; await Task.WhenAll(NewComments.AddRangeAsync(this._innerComment.Comments), HotComments.AddRangeAsync(this._innerComment.HotComments)); // RaiseAllPropertyChanged(); } } }
public void AddToCommentsCollection(CommentModel model) { HotComments.Add(model); }
/// <summary> /// 刷新热门评论 /// </summary> public async void RefreshHotComments() { await HotComments.ClearAndReloadAsync(); }