Esempio n. 1
0
        public void LoadMoreComments(int countToLoad, Action <bool> callback)
        {
            if (this._isLoadingComments)
            {
                return;
            }
            this._isLoadingComments = true;
            MarketService            instance           = MarketService.Instance;
            long                     ownerId            = this.OwnerId;
            long                     itemId             = this.ItemId;
            int                      totalCommentsCount = this.TotalCommentsCount;
            ProductLikesCommentsData likesCommentsData  = this._likesCommentsData;
            int?                     nullable;

            if (likesCommentsData == null)
            {
                nullable = new int?();
            }
            else
            {
                List <Comment> comments = likesCommentsData.Comments;
                nullable = comments != null ? new int?((comments.Count)) : new int?();
            }
            int offset = nullable ?? 0;
            int count  = countToLoad;
            Action <BackendResult <ProductLikesCommentsData, ResultCode> > callback1 = (Action <BackendResult <ProductLikesCommentsData, ResultCode> >)(res =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    if (this._likesCommentsData == null)
                    {
                        this._likesCommentsData = res.ResultData;
                        this.TotalCommentsCount = this._likesCommentsData.TotalCommentsCount;
                    }
                    else
                    {
                        List <Comment> comments = this._likesCommentsData.Comments;
                        this._likesCommentsData.Comments = res.ResultData.Comments;
                        this._likesCommentsData.Comments.AddRange((IEnumerable <Comment>)comments);
                        this._likesCommentsData.users.AddRange((IEnumerable <User>)res.ResultData.users);
                        this._likesCommentsData.groups.AddRange((IEnumerable <Group>)res.ResultData.groups);
                    }
                    callback(true);
                }
                else
                {
                    callback(false);
                }
                this._isLoadingComments = false;
            });

            instance.GetComments(ownerId, itemId, totalCommentsCount, offset, count, callback1);
        }
Esempio n. 2
0
 public void GetComments(long ownerId, long productId, int knownCount, int offset, int count, Action <BackendResult <ProductLikesCommentsData, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <ProductLikesCommentsData>("execute.getProductComments", new Dictionary <string, string>()
     {
         {
             "owner_id",
             ownerId.ToString()
         },
         {
             "product_id",
             productId.ToString()
         },
         {
             "count",
             count.ToString()
         },
         {
             "offset",
             offset.ToString()
         },
         {
             "known_count",
             knownCount.ToString()
         },
         {
             "func_v",
             "2"
         }
     }, callback, (Func <string, ProductLikesCommentsData>)(jsonStr =>
     {
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "users", false);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "users2", false);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "users3", false);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "groups", false);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "comments", true);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "tags", false);
         jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "likesAllIds", false);
         ProductLikesCommentsData response = JsonConvert.DeserializeObject <GenericRoot <ProductLikesCommentsData> >(jsonStr).response;
         GroupsService.Current.AddCachedGroups((IEnumerable <Group>)response.groups);
         if (knownCount < 0)
         {
             response.Comments.Reverse();
         }
         response.users2.AddRange((IEnumerable <User>)response.users3);
         return(response);
     }), false, true, new CancellationToken?(), null);
 }
        private void Unlike()
        {
            LikesService.Current.AddRemoveLike(false, this.OwnerId, this.ItemId, LikeObjectType.market, (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(res =>
            {
                EventAggregator current = EventAggregator.Current;
                ProductFavedUnfavedEvent favedUnfavedEvent = new ProductFavedUnfavedEvent();
                favedUnfavedEvent.Product = this._product;
                int num = 0;
                favedUnfavedEvent.IsFaved = num != 0;
                current.Publish(favedUnfavedEvent);
            }), "");
            ProductLikesCommentsData likesCommentsData = this._likesCommentsData;
            int?likesAllCount = likesCommentsData.likesAllCount;
            int?nullable      = likesAllCount.HasValue ? new int?(likesAllCount.GetValueOrDefault() - 1) : new int?();

            likesCommentsData.likesAllCount   = nullable;
            this._likesCommentsData.UserLiked = 0;
        }
        public void LoadMoreComments(int countToLoad, Action <bool> callback)
        {
            if (this._isLoadingComments)
            {
                return;
            }
            this._isLoadingComments = true;
            MarketService            instance           = MarketService.Instance;
            long                     ownerId            = this.OwnerId;
            long                     itemId             = this.ItemId;
            int                      totalCommentsCount = this.TotalCommentsCount;
            ProductLikesCommentsData likesCommentsData  = this._likesCommentsData;
            int?                     nullable;

            if (likesCommentsData == null)
            {
                nullable = new int?();
            }
            else
            {
                List <Comment> comments = likesCommentsData.Comments;
                // ISSUE: explicit non-virtual call
                nullable = comments != null ? new int?(comments.Count) : new int?();
            }
            int offset = nullable ?? 0;
            int count  = countToLoad;
            Action <BackendResult <ProductLikesCommentsData, ResultCode> > callback1 = (Action <BackendResult <ProductLikesCommentsData, ResultCode> >)(res =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    if (this._likesCommentsData == null)
                    {
                        if (!res.ResultData.likesAllCount.HasValue)
                        {
                            callback(false);
                            this._isLoadingComments = false;
                            Execute.ExecuteOnUIThread((Action)(() =>
                            {
                                MessageBox.Show(CommonResources.PrivateGroupProductError, CommonResources.AccessError, (MessageBoxButton)0);
                                Navigator.Current.GoBack();
                            }));
                            return;
                        }
                        this._likesCommentsData = res.ResultData;
                        this.TotalCommentsCount = this._likesCommentsData.TotalCommentsCount;
                    }
                    else
                    {
                        List <Comment> comments = this._likesCommentsData.Comments;
                        this._likesCommentsData.Comments = res.ResultData.Comments;
                        this._likesCommentsData.Comments.AddRange((IEnumerable <Comment>)comments);
                        this._likesCommentsData.users.AddRange((IEnumerable <User>)res.ResultData.users);
                        this._likesCommentsData.groups.AddRange((IEnumerable <Group>)res.ResultData.groups);
                    }
                    callback(true);
                }
                else
                {
                    callback(false);
                }
                this._isLoadingComments = false;
            });

            instance.GetComments(ownerId, itemId, totalCommentsCount, offset, count, callback1);
        }