public void Restore(System.Collections.Generic.IDictionary <string, object> state) { if (state.ContainsKey("PageComments")) { Comments = state["PageComments"] as ObservableCollection <VoteViewModel>; result = state["PageResult"] as PagedResultOfCommentEntryDTO5oAtqRlh; loaded = (bool)state["Loaded"]; entry = (IRatingable)state["Entry"]; updateNoRatingsLabel(); } //setCommentsStatus(); }
public void Load(IRatingable exercise) { entry = exercise; var m = new ServiceManager <GetCommentsCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetCommentsCompletedEventArgs> operationCompleted) { client1.GetCommentsCompleted -= operationCompleted; client1.GetCommentsCompleted += operationCompleted; client1.GetCommentsAsync(ApplicationState.Current.SessionData.Token, entry.GlobalId, new PartialRetrievingInfo()); }); m.OperationCompleted += (s, a) => { refreshRequired = false; if (a.Error != null) { onCommentsLoaded(); BAMessageBox.ShowError(ApplicationStrings.VotesControl_ErrRetrieveRatings); return; } else { Comments.Clear(); result = a.Result.Result; foreach (var item in a.Result.Result.Items) { Comments.Add(new VoteViewModel(item)); } updateNoRatingsLabel(); loaded = true; //setCommentsStatus(); } onCommentsLoaded(); }; if (!m.Run()) { onCommentsLoaded(); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
public void LoadMore() { var m = new ServiceManager <GetCommentsCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetCommentsCompletedEventArgs> operationCompleted) { client1.GetCommentsAsync(ApplicationState.Current.SessionData.Token, entry.GlobalId, new PartialRetrievingInfo() { PageIndex = result.PageIndex + 1 }); client1.GetCommentsCompleted -= operationCompleted; client1.GetCommentsCompleted += operationCompleted; }); m.OperationCompleted += (s, a) => { if (a.Error != null) { onCommentsLoaded(); BAMessageBox.ShowError(ApplicationStrings.VotesControl_ErrRetrieveRatings); return; } else { result = a.Result.Result; foreach (var item in a.Result.Result.Items) { Comments.Add(new VoteViewModel(item)); } } onCommentsLoaded(); }; if (!m.Run()) { onCommentsLoaded(); BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } }