Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }