Exemplo n.º 1
0
 internal void Share(string text = "", long gid = 0, string groupName = "")
 {
     if (this._wallPostData == null)
     {
         return;
     }
     this._wallPostData.WallPost.reposts.user_reposted = 1;
     this.UpdateCanSomethingProperties();
     WallService.Current.Repost(this._ownerId, this._postId, text, this._wallPostData.WallPost.GetRepostObjectType(), gid, (Action <BackendResult <RepostResult, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         if (res.ResultCode == ResultCode.Succeeded)
         {
             GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, gid, groupName);
             if (gid != 0L || this.Liked)
             {
                 return;
             }
             this.Liked = true;
             EventAggregator current = EventAggregator.Current;
             WallItemLikedUnliked itemLikedUnliked = new WallItemLikedUnliked();
             itemLikedUnliked.OwnerId = this._wallPostData.WallPost.to_id;
             itemLikedUnliked.WallPostId = this._wallPostData.WallPost.id;
             int num = 1;
             itemLikedUnliked.Liked = num != 0;
             current.Publish((object)itemLikedUnliked);
         }
         else
         {
             new GenericInfoUC().ShowAndHideLater(CommonResources.Error, null);
         }
     }))));
 }
Exemplo n.º 2
0
        private void ActiveStickers_OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (this._updatingCollection || e.Action != NotifyCollectionChangedAction.Add)
            {
                return;
            }
            int before = 0;
            int after  = 0;
            int index  = e.NewStartingIndex;
            int id     = this.ActiveStickers[index].Product.id;

            if (index > 0)
            {
                after = this.ActiveStickers[index - 1].Product.id;
            }
            if (index < this.ActiveStickers.Count - 1)
            {
                before = this.ActiveStickers[index + 1].Product.id;
            }
            this.SetProgress(true);
            StoreService.Instance.ReorderProducts(id, after, before, (Action <BackendResult <bool, ResultCode> >)(result =>
            {
                this.SetProgress(false);
                if (result.ResultCode != ResultCode.Succeeded)
                {
                    GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
                else
                {
                    EventAggregator.Current.Publish((object)new StickersPacksReorderedEvent(this.ActiveStickers[index].StockItem, index));
                }
            }));
        }
Exemplo n.º 3
0
 internal void DeletePhoto()
 {
     this.SetInProgress(true, "");
     AccountService.Instance.DeleteProfilePhoto((Action <BackendResult <User, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         this.SetInProgress(false, "");
         if (res.ResultCode != ResultCode.Succeeded)
         {
             return;
         }
         if (this._profileInfo != null)
         {
             if (AppGlobalStateManager.Current.GlobalState.LoggedInUser == null)
             {
                 return;
             }
             AppGlobalStateManager.Current.GlobalState.LoggedInUser.photo_max = res.ResultData.photo_max;
             EventAggregator.Current.Publish((object)new BaseDataChangedEvent()
             {
                 IsProfileUpdateRequired = true
             });
         }
         else
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
         }
     }))));
 }
Exemplo n.º 4
0
 public void Save()
 {
     if (!this.CanSave)
     {
         return;
     }
     this.IsSaving = true;
     this.SetInProgress(true, "");
     AccountService.Instance.SaveSettingsAccountInfo(this._updateDictionary, (Action <BackendResult <SaveProfileResponse, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         this.IsSaving = false;
         this.SetInProgress(false, "");
         if (res.ResultCode == ResultCode.Succeeded)
         {
             if (this._updateDictionary.ContainsKey("first_name") || this._updateDictionary.ContainsKey("last_name"))
             {
                 int num = (int)MessageBox.Show(CommonResources.Settings_EditProfile_ChangeNameRequestDesc, CommonResources.Settings_EditProfile_ChangeNameRequest, MessageBoxButton.OK);
             }
             EventAggregator.Current.Publish((object)new BaseDataChangedEvent()
             {
                 IsProfileUpdateRequired = true
             });
             Navigator.Current.GoBack();
         }
         else
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
         }
     }))) /*, this._uploadResponseData*/);
 }
Exemplo n.º 5
0
        internal void CancelNameRequest()
        {
            if (this._profileInfo == null || this._profileInfo.name_request == null || (this._profileInfo.name_request.id == 0L || this.IsSaving))
            {
                return;
            }
            this.IsSaving = true;
            this.SetInProgress(true, "");
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["cancel_request_id"] = this._profileInfo.name_request.id.ToString();
            AccountService.Instance.SaveSettingsAccountInfo(parameters, (Action <BackendResult <SaveProfileResponse, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
            {
                this.IsSaving = false;
                this.SetInProgress(false, "");
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    this._profileInfo.name_request = (NameChangeRequest)null;
                    this.NotifyPropertyChanged <bool>((System.Linq.Expressions.Expression <Func <bool> >)(() => this.HaveNameRequestInProgress));
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
            }))), (UploadPhotoResponseData)null);
        }
Exemplo n.º 6
0
 public void LoadData()
 {
     if (this._isLoading)
     {
         return;
     }
     this._isLoading = true;
     base.SetInProgress(true, "");
     AccountService.Instance.GetSettingsAccountInfo(delegate(BackendResult <SettingsAccountInfo, ResultCode> res)
     {
         base.SetInProgress(false, "");
         if (res.ResultCode != ResultCode.Succeeded)
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null);
         }
         else
         {
             Execute.ExecuteOnUIThread(delegate
             {
                 this.ReadData(res.ResultData);
             });
         }
         this._isLoading = false;
     });
 }
Exemplo n.º 7
0
        public void LeaveChat()
        {
            this.IsChatLeaving = true;
            this.SetInProgress(true, "");
            IChatService chatService      = BackendServices.ChatService;
            long         chatId           = this._chatId;
            List <long>  usersToBeRemoved = new List <long>();

            usersToBeRemoved.Add(AppGlobalStateManager.Current.LoggedInUserId);
            Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> > callback = (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    this._navigationService.RemoveBackEntrySafe();
                    this._navigationService.GoBackSafe();
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
                this.SetInProgress(false, "");
                this.IsChatLeaving = false;
            })));

            chatService.RemoveChatUsers(chatId, usersToBeRemoved, callback);
        }
Exemplo n.º 8
0
        public void ExcludeMember(ChatMember member)
        {
            this.SetInProgress(true, "");
            member.ExcludeButtonVisibility = Visibility.Collapsed;
            IChatService chatService      = BackendServices.ChatService;
            long         chatId           = this._chatId;
            List <long>  usersToBeRemoved = new List <long>();

            usersToBeRemoved.Add(member.Id);
            Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> > callback = (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    this.Members.Remove(member);
                }
                else
                {
                    member.ExcludeButtonVisibility = Visibility.Visible;
                    GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
                this.SetInProgress(false, "");
            })));

            chatService.RemoveChatUsers(chatId, usersToBeRemoved, callback);
        }
 public void UpdatePhoto(Stream photoStream, Rect crop)
 {
     this.IsPhotoChanging = true;
     this.SetInProgress(true, "");
     ImagePreprocessor.PreprocessImage(photoStream, VKConstants.ResizedImageSize, true, (Action<ImagePreprocessResult>)(resized =>
     {
         Stream stream = resized.Stream;
         byte[] photoData = ImagePreprocessor.ReadFully(stream);
         stream.Close();
         BackendServices.MessagesService.UpdateChatPhoto(this.ChatId, photoData, ImagePreprocessor.GetThumbnailRect((double)resized.Width, (double)resized.Height, crop), (Action<BackendResult<ChatInfoWithMessageId, ResultCode>>)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this._chatInformation.chat.photo_200 = result.ResultData.chat.photo_200;
                 this.NotifyPropertyChanged<string>((Expression<Func<string>>)(() => this.Photo));
                 this.NotifyPropertyChanged<Visibility>((Expression<Func<Visibility>>)(() => this.PhotoPlaceholderVisibility));
                 this.NotifyPropertyChanged<bool>((Expression<Func<bool>>)(() => this.IsPhotoMenuEnabled));
             }
             else
                 GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null);
             this.SetInProgress(false, "");
             this.IsPhotoChanging = false;
         }))));
     }));
 }
Exemplo n.º 10
0
        public void DeletePhoto(Photo photo)
        {
            Func <AlbumPhoto, bool> func;

            PhotosService.Current.DeletePhoto(photo.pid, this.OwnerId, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    AlbumPhoto albumPhoto = this._albumPhotos.FirstOrDefault <AlbumPhoto>((func = (Func <AlbumPhoto, bool>)(ap => ap.Photo.pid == photo.pid)));
                    if (albumPhoto != null)
                    {
                        this._albumPhotos.Remove(albumPhoto);
                        this.RebindHeadersToAlbumPhotos();
                        this.PhotosCount = this.PhotosCount - 1;
                        --this._photosGenCol.TotalCount;
                    }
                    EventAggregator.Current.Publish((object)new PhotoDeletedFromAlbum()
                    {
                        OwnerId = this.OwnerId,
                        AlbumId = this._albumId,
                        PhotoId = photo.pid
                    });
                    this.UpdateThumbAfterPhotosMoving();
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null);
                }
            }))));
        }
Exemplo n.º 11
0
        internal void AddRemoveToMyVideos()
        {
            if (this._isAddingRemoving)
            {
                return;
            }
            this._isAddingRemoving = false;
            bool add = this.CanAddToMyVideos;

            VideoService.Instance.AddRemovedToFromAlbum(add, AppGlobalStateManager.Current.LoggedInUserId, VideoAlbum.ADDED_ALBUM_ID, this.OwnerId, this.VideoId, (Action <BackendResult <ResponseWithId, ResultCode> >)(res =>
            {
                this._isAddingRemoving = false;
                string successString   = add ? CommonResources.VideoNew_VideoHasBeenAddedToMyVideos : CommonResources.VideoNew_VideoHasBeenRemovedFromMyVideos;
                GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, successString, null);
                if (res.ResultCode != ResultCode.Succeeded || this._likesCommentsData == null || this._likesCommentsData.Albums == null)
                {
                    return;
                }
                if (add)
                {
                    this._likesCommentsData.Albums.Add(VideoAlbum.ADDED_ALBUM_ID);
                }
                else
                {
                    this._likesCommentsData.Albums.Remove(VideoAlbum.ADDED_ALBUM_ID);
                }
            }));
        }
Exemplo n.º 12
0
        private static void HandleStorePurchaseError(BackendResult <StorePurchaseResult, ResultCode> result, Action callback = null)
        {
            ResultCode resultCode = result.ResultCode;

            switch (resultCode)
            {
            case ResultCode.Succeeded:
                if (result.ResultData != null && result.ResultData.state < 0)
                {
                    Execute.ExecuteOnUIThread((Action)(() => new GenericInfoUC(2000).ShowAndHideLater(result.ResultData.error_message ?? CommonResources.UnableToCompletePurchase, null)));
                    break;
                }
                break;

            case ResultCode.ValidationCancelledOrFailed:
                return;

            case ResultCode.ConfirmationCancelled:
                return;

            case ResultCode.BalanceRefillCancelled:
                return;

            default:
                GenericInfoUC.ShowBasedOnResult((int)resultCode, "", (VKRequestsDispatcher.Error)null);
                break;
            }
            if (callback == null)
            {
                return;
            }
            callback();
        }
Exemplo n.º 13
0
 private void PerformLogin(Action <bool> resultCallback)
 {
     if (this.IsInProgress)
     {
         return;
     }
     this.SetInProgress(true, "");
     LoginService.Instance.GetAccessToken(this._registrationPhoneNumberVM.PhoneNumberString, this._registrationPasswordVM.PasswordStr, (Action <BackendResult <AutorizationData, ResultCode> >)(result =>
     {
         this.SetInProgress(false, "");
         Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this.HandleLogin(result);
                 resultCallback(true);
             }
             else
             {
                 GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                 resultCallback(false);
             }
         }));
     }));
 }
 public void ChangeTitle(string newTitle, Action errorAction)
 {
     if (string.IsNullOrWhiteSpace(newTitle) || newTitle.Length < 2)
     {
         errorAction();
     }
     else
     {
         this.SetInProgress(true, "");
         this.IsTitleBoxEnabled = false;
         BackendServices.ChatService.EditChat(this._chatId, newTitle, (Action<BackendResult<VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode>>)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this._chatInformation.chat.title = newTitle;
                 this.NotifyPropertyChanged<string>((Expression<Func<string>>)(() => this.Title));
             }
             else
             {
                 errorAction();
                 GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null);
             }
             this.SetInProgress(false, "");
             this.IsTitleBoxEnabled = true;
         }))));
     }
 }
Exemplo n.º 15
0
        public void ShareToGroup(string text, long groupId, string groupName)
        {
            WallPostRequestData postData = new WallPostRequestData()
            {
                message       = text,
                AttachmentIds = new List <string>()
                {
                    this._product.ToString()
                }
            };

            if (groupId != 0L)
            {
                postData.owner_id        = -groupId;
                postData.OnBehalfOfGroup = true;
            }
            WallService.Current.Post(postData, (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, groupId, groupName);
                }
                else
                {
                    new GenericInfoUC().ShowAndHideLater(CommonResources.Error, (FrameworkElement)null);
                }
            }))));
        }
Exemplo n.º 16
0
        public void CancelTransfer(Action callback = null)
        {
            FullscreenLoader loader = new FullscreenLoader();

            loader.Show(null, true);
            MoneyTransfersService.DeclineTransfer(this.Transfer.id, (Action <BackendResult <int, ResultCode> >)(result =>
            {
                loader.Hide(false);
                ResultCode resultCode = result.ResultCode;
                if (resultCode == ResultCode.Succeeded)
                {
                    this.Transfer.status = 2;
                    EventAggregator.Current.Publish(new MoneyTransferDeclinedEvent(this.Transfer));
                    Action action = callback;
                    if (action == null)
                    {
                        return;
                    }
                    action.Invoke();
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult(resultCode, "", (VKRequestsDispatcher.Error)null);
                }
            }));
        }
Exemplo n.º 17
0
        public void AddMember(User user)
        {
            this.IsMemberAdding = true;
            this.SetInProgress(true, "");
            IChatService chatService = BackendServices.ChatService;
            long         chatId      = this._chatId;
            List <long>  userIds     = new List <long>();

            userIds.Add(user.id);
            Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> > callback = (Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    User loggedInUser = AppGlobalStateManager.Current.GlobalState.LoggedInUser;
                    this.Members.Add(new ChatMember(new ChatUser(user, loggedInUser.id), loggedInUser, long.Parse(this._chatInformation.chat.admin_id)));
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult(result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
                this.SetInProgress(false, "");
                this.IsMemberAdding = false;
            })));

            chatService.AddChatUsers(chatId, userIds, callback);
        }
Exemplo n.º 18
0
        private static void ShowWithLoader(string referrer, Action <Action <BackendResult <StockItem, ResultCode> >, CancellationToken> loadAction, long userOrChatId = 0, bool isChat = false)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            FullscreenLoader        fullscreenLoader        = new FullscreenLoader();

            fullscreenLoader.HideOnBackKeyPress = true;
            Action <FullscreenLoaderHiddenEventArgs> action = (Action <FullscreenLoaderHiddenEventArgs>)(args => cancellationTokenSource.Cancel());

            fullscreenLoader.HiddenCallback = action;
            FullscreenLoader loader = fullscreenLoader;

            loader.Show(null, true);
            loadAction((Action <BackendResult <StockItem, ResultCode> >)(result =>
            {
                loader.Hide(false);
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    Execute.ExecuteOnUIThread((Action)(() => StickersPackView.Show(result.ResultData, referrer, userOrChatId, isChat)));
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
            }), cancellationTokenSource.Token);
        }
Exemplo n.º 19
0
 public void AddDocument()
 {
     if (this._doc == null || this._isGifAdded || this._isAddingDoc)
     {
         return;
     }
     this._isAddingDoc = true;
     this.SetInProgressMain(true, "");
     DocumentsService.Current.Add(this._doc.owner_id, this._doc.id, this._doc.access_key, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(res =>
     {
         this._isAddingDoc = false;
         this.SetInProgressMain(false, "");
         if (res.ResultCode == ResultCode.Succeeded)
         {
             this._isGifAdded = true;
             // ISSUE: type reference
             // ISSUE: method reference
             this.NotifyPropertyChanged <Visibility>((System.Linq.Expressions.Expression <Func <Visibility> >)(() => this.CanAddVisibility));
             this.NotifyPropertyChanged <Visibility>((System.Linq.Expressions.Expression <Func <Visibility> >)(() => this.AddedVisibility));
             GenericInfoUC.ShowBasedOnResult(0, CommonResources.FileIsSavedInDocuments, (VKRequestsDispatcher.Error)null);
         }
         else if (res.ResultCode == ResultCode.WrongParameter && res.Error.error_msg.Contains("already added"))
         {
             GenericInfoUC.ShowBasedOnResult(0, CommonResources.FileIsAlreadySavedInDocuments, (VKRequestsDispatcher.Error)null);
         }
         else
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null);
         }
     }));
 }
Exemplo n.º 20
0
        public void CreateCommunity()
        {
            string type               = "group";
            int    subtype            = 0;
            bool?  publicPageSelected = this.IsPublicPageSelected;
            bool   flag1              = true;

            if ((publicPageSelected.GetValueOrDefault() == flag1 ? (publicPageSelected.HasValue ? 1 : 0) : 0) != 0)
            {
                type = "public";
                bool?isPlaceSelected = this.IsPlaceSelected;
                bool flag2           = true;
                if ((isPlaceSelected.GetValueOrDefault() == flag2 ? (isPlaceSelected.HasValue ? 1 : 0) : 0) != 0)
                {
                    subtype = 1;
                }
                else
                {
                    bool?isCompanySelected = this.IsCompanySelected;
                    bool flag3             = true;
                    if ((isCompanySelected.GetValueOrDefault() == flag3 ? (isCompanySelected.HasValue ? 1 : 0) : 0) != 0)
                    {
                        subtype = 2;
                    }
                    else
                    {
                        bool?isPersonSelected = this.IsPersonSelected;
                        bool flag4            = true;
                        subtype = (isPersonSelected.GetValueOrDefault() == flag4 ? (isPersonSelected.HasValue ? 1 : 0) : 0) == 0 ? 4 : 3;
                    }
                }
            }
            else
            {
                bool?isEventSelected = this.IsEventSelected;
                bool flag2           = true;
                if ((isEventSelected.GetValueOrDefault() == flag2 ? (isEventSelected.HasValue ? 1 : 0) : 0) != 0)
                {
                    type = "event";
                }
            }
            this.SetInProgress(true, "");
            this.IsFormEnabled = false;
            GroupsService.Current.CreateCommunity(this.Name, type, subtype, (Action <BackendResult <Group, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    EventAggregator.Current.Publish((object)new GroupMembershipStatusUpdated(result.ResultData.id, true));
                    Navigator.Current.NavigateToGroup(result.ResultData.id, "", false);
                    this._navigationService.RemoveBackEntry();
                }
                else
                {
                    this.SetInProgress(false, "");
                    this.IsFormEnabled = true;
                    GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", null);
                }
            }))));
        }
Exemplo n.º 21
0
        private void publishNowMenuItem_Click(object sender, RoutedEventArgs e)
        {
            WallPostViewModel wallPostViewModel = new WallPostViewModel(this._wallPost, this.AdminLevel, (WallRepostInfo)null);

            wallPostViewModel.WMMode = WallPostViewModel.Mode.PublishWallPost;
            wallPostViewModel.IsPublishSuggestedSuppressed = true;
            IOutboundAttachment timerAttachment = wallPostViewModel.OutboundAttachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.AttachmentId == "timestamp"));

            if (timerAttachment != null)
            {
                wallPostViewModel.OutboundAttachments.Remove(timerAttachment);
            }
            wallPostViewModel.Publish((Action <ResultCode>)(res => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (res == ResultCode.Succeeded)
                {
                    if (this._wallPost.IsFromGroup())
                    {
                        long groupId = -this._wallPost.owner_id;
                        Group group = this._groups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == groupId));
                        if (group == null)
                        {
                            return;
                        }
                        GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, groupId, group.name);
                    }
                    else if (this._wallPost.owner_id >= 0L)
                    {
                        GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, 0L, "");
                    }
                    else
                    {
                        long communityId = -this._wallPost.owner_id;
                        Group group = this._groups.FirstOrDefault <Group>((Func <Group, bool>)(g => g.id == communityId));
                        if (group == null)
                        {
                            return;
                        }
                        GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.WallPost, communityId, group.name);
                    }
                }
                else if (res == ResultCode.PostsLimitOrAlreadyScheduled)
                {
                    if (timerAttachment != null)
                    {
                        new GenericInfoUC(2000).ShowAndHideLater(CommonResources.ScheduledForExistingTime, null);
                    }
                    else
                    {
                        new GenericInfoUC(2000).ShowAndHideLater(CommonResources.PostsLimitReached, null);
                    }
                }
                else
                {
                    new GenericInfoUC(2000).ShowAndHideLater(CommonResources.Error, null);
                }
            }))));
        }
Exemplo n.º 22
0
        public void SavePoll(Action <Poll> successCallback)
        {
            if (this.IsInProgress)
            {
                return;
            }
            this.SetInProgress(true, "");
            this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanSave));
            if (this._mode == CreateEditPollViewModel.Mode.Create)
            {
                PollService.Current.CreatePoll(this.Question, this.IsAnonymous, this._ownerId, this.ValidPollOptions.Select <PollOption, string>((Func <PollOption, string>)(p => p.Text)).ToList <string>(), (Action <BackendResult <Poll, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
                {
                    this.SetInProgress(false, "");
                    this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanSave));
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        successCallback(res.ResultData);
                    }
                    else
                    {
                        GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
                    }
                }))));
            }
            else
            {
                List <string>            list1  = this.ValidPollOptions.Where <PollOption>((Func <PollOption, bool>)(p => p.AnswerId == 0L)).Select <PollOption, string>((Func <PollOption, string>)(p => p.Text)).ToList <string>();
                IEnumerable <PollOption> source = this.ValidPollOptions.Where <PollOption>((Func <PollOption, bool>)(p =>
                {
                    if (p.AnswerId != 0L)
                    {
                        return(p.IsChanged);
                    }
                    return(false);
                }));
                Func <PollOption, string> func = (Func <PollOption, string>)(p => p.AnswerId.ToString());

                Func <PollOption, string> keySelector = new Func <PollOption, string>(p => p.Text);


                Dictionary <string, string> dictionary = source.ToDictionary <PollOption, string, string>(keySelector, (Func <PollOption, string>)(p => p.Text));
                List <long> list2 = this._initialPoll.answers.Select <Answer, long>((Func <Answer, long>)(a => a.id)).Except <long>(this.ValidPollOptions.Select <PollOption, long>((Func <PollOption, long>)(p => p.AnswerId))).ToList <long>();
                PollService.Current.EditPoll(this._ownerId, this._pollId, this.Question, list1, dictionary, list2, (Action <BackendResult <Poll, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
                {
                    this.SetInProgress(false, "");
                    this.NotifyPropertyChanged <bool>((Expression <Func <bool> >)(() => this.CanSave));
                    if (res.ResultCode == ResultCode.Succeeded)
                    {
                        successCallback(res.ResultData);
                    }
                    else
                    {
                        GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
                    }
                }))));
            }
        }
Exemplo n.º 23
0
 private static void ReportAdWallPost(string adData)
 {
     PickerUC.ShowPickerFor(ReportContentHelper.GetPredefinedAdReportReasons(), (PickableItem)null, (Action <PickableItem>)(pi => AdsIntService.ReportAd(adData, (ReportAdReason)pi.ID, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(res =>
     {
         EventAggregator.Current.Publish((object)new AdReportedEvent()
         {
             AdData = adData
         });
         GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, CommonResources.ReportSent, (VKRequestsDispatcher.Error)null);
     }))), (Action <PickableItem>)null, null, CommonResources.PostContains);
 }
Exemplo n.º 24
0
        private void SendAsAGift_OnTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (this._stockItemHeader == null)
            {
                return;
            }
            EventAggregator.Current.Publish(new GiftsPurchaseStepsEvent(GiftPurchaseStepsSource.stickers_present, GiftPurchaseStepsAction.store));
            EventAggregator.Current.Publish(new StickersPurchaseFunnelEvent(StickersPurchaseFunnelAction.present_button_clicked));
            long productId    = (long)this._stockItemHeader.ProductId;
            long userOrChatId = this._stockItemHeader.UserOrChatId;
            bool isChat       = this._stockItemHeader.IsChat;

            if (productId == 0L || userOrChatId == 0L)
            {
                return;
            }
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            FullscreenLoader        fullscreenLoader        = new FullscreenLoader();

            fullscreenLoader.HideOnBackKeyPress = true;
            Action <FullscreenLoaderHiddenEventArgs> action = (Action <FullscreenLoaderHiddenEventArgs>)(args => cancellationTokenSource.Cancel());

            fullscreenLoader.HiddenCallback = action;
            FullscreenLoader loader = fullscreenLoader;

            loader.Show(null, true);
            GiftsService.Instance.GetGiftInfoFromStore(productId, userOrChatId, isChat, (Action <BackendResult <GiftInfoFromStoreResponse, ResultCode> >)(result =>
            {
                loader.Hide(false);
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    GiftInfoFromStoreResponse resultData = result.ResultData;
                    List <long> userIds       = resultData.userIds;
                    GiftsSectionItem giftItem = resultData.giftItem;
                    Gift gift = giftItem.gift;
                    if (userIds == null || userIds.Count == 0)
                    {
                        Execute.ExecuteOnUIThread((Action)(() => MessageBox.Show(isChat ? CommonResources.AllChatParticipantsHaveStickerPack : CommonResources.UserAlreadyHasStickerPack, CommonResources.StickerPack, (MessageBoxButton)0)));
                    }
                    else
                    {
                        if (giftItem == null || gift == null)
                        {
                            return;
                        }
                        Navigator.Current.NavigateToGiftSend(gift.id, "stickers", giftItem.description, gift.thumb_256, giftItem.price, giftItem.gifts_left, userIds, true);
                    }
                }
                else
                {
                    GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", (VKRequestsDispatcher.Error)null);
                }
            }), new CancellationToken?(cancellationTokenSource.Token));
        }
 public void Save(Action <bool> resultCallback)
 {
     this._isSaving = true;
     this.SetInProgress(true, "");
     if (this.IsNewAlbum)
     {
         VideoService.Instance.AddAlbum(this.Name, this.AlbumPrivacyVM.GetAsPrivacyInfo(), (Action <BackendResult <VideoAlbum, ResultCode> >)(res =>
         {
             this._isSaving = false;
             this.SetInProgress(false, "");
             if (res.ResultCode != ResultCode.Succeeded)
             {
                 Execute.ExecuteOnUIThread((Action)(() => GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null)));
             }
             else
             {
                 EventAggregator current = EventAggregator.Current;
                 VideoAlbumAddedDeletedEvent addedDeletedEvent = new VideoAlbumAddedDeletedEvent();
                 addedDeletedEvent.AlbumId = this._albumId;
                 addedDeletedEvent.OwnerId = this._groupId > 0L ? -this._groupId : AppGlobalStateManager.Current.LoggedInUserId;
                 int num = 1;
                 addedDeletedEvent.IsAdded = num != 0;
                 current.Publish((object)addedDeletedEvent);
             }
             resultCallback(res.ResultCode == ResultCode.Succeeded);
         }), new long?(this._groupId));
     }
     else
     {
         VideoService.Instance.EditAlbum(this.Name, this._albumId, this.AlbumPrivacyVM.GetAsPrivacyInfo(), (Action <BackendResult <object, ResultCode> >)(res =>
         {
             this._isSaving = false;
             this.SetInProgress(false, "");
             if (res.ResultCode != ResultCode.Succeeded)
             {
                 Execute.ExecuteOnUIThread((Action)(() => GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null)));
             }
             else
             {
                 EventAggregator.Current.Publish((object)new VideoAlbumEditedEvent()
                 {
                     AlbumId = this._albumId,
                     OwnerId = (this._groupId > 0L ? -this._groupId : AppGlobalStateManager.Current.LoggedInUserId),
                     Name    = this.Name,
                     Privacy = this.AlbumPrivacyVM.GetAsPrivacyInfo()
                 });
             }
             resultCallback(res.ResultCode == ResultCode.Succeeded);
         }), new long?(this._groupId));
     }
 }
Exemplo n.º 26
0
 internal void UpdatePrivacy(EditPrivacyViewModel vm, PrivacyInfo pi)
 {
     AccountService.Instance.SetPrivacy(vm.Key, pi.ToString(), (Action <BackendResult <ResponseWithId, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         if (res.ResultCode != ResultCode.Succeeded)
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
         }
         else
         {
             vm.ReadFromPrivacyInfo(pi);
         }
     }))));
 }
Exemplo n.º 27
0
 private void RequestVoiceCall(Action <bool> resultCallback)
 {
     if (this.IsInProgress)
     {
         return;
     }
     this.SetInProgress(true, "");
     SignUpService.Instance.SignUp(this._registrationPhoneNumberVM.PhoneNumberString, this._registrationProfileVM.FirstName, this._registrationProfileVM.LastName, true, this._registrationProfileVM.IsMale, this._sid, (Action <BackendResult <string, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         this.SetInProgress(false, "");
         GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
         resultCallback(res.ResultCode == ResultCode.Succeeded);
     }))));
 }
Exemplo n.º 28
0
        public void AcceptTransfer()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
//      MoneyTransferViewModel.<>c__DisplayClass61_1 cDisplayClass611_1 = new MoneyTransferViewModel.<>c__DisplayClass61_1();
            // ISSUE: reference to a compiler-generated field
//      cDisplayClass611_1.<>4__this = this;
            if (this.Transfer == null)
            {
                return;
            }
            // ISSUE: reference to a compiler-generated field
            string acceptUrl = this.Transfer.accept_url;

            // ISSUE: reference to a compiler-generated field
            if (!string.IsNullOrEmpty(acceptUrl))
            {
                // ISSUE: reference to a compiler-generated field
                this.AcceptTransfer(acceptUrl);
            }
            else
            {
                FullscreenLoader loader = new FullscreenLoader();
                loader.Show(null, true);
                MoneyTransfersService.CheckTransfer(this.Transfer.id, this.Transfer.from_id, this.Transfer.to_id, (Action <BackendResult <MoneyTransfer, ResultCode> >)(result =>
                {
                    loader.Hide(false);
                    ResultCode resultCode = result.ResultCode;
                    if (resultCode == ResultCode.Succeeded)
                    {
                        // ISSUE: variable of a compiler-generated type
//            MoneyTransferViewModel.<>c__DisplayClass61_1 cDisplayClass611_2 = cDisplayClass611_1;
                        MoneyTransfer resultData = result.ResultData;
                        string str = resultData != null ? resultData.accept_url :  null;
                        // ISSUE: reference to a compiler-generated field
                        acceptUrl = str;
                        if (string.IsNullOrEmpty(acceptUrl))
                        {
                            return;
                        }
                        this.AcceptTransfer(acceptUrl);
                    }
                    else
                    {
                        GenericInfoUC.ShowBasedOnResult(resultCode, "", null);
                    }
                }));
            }
        }
Exemplo n.º 29
0
 internal void Share(string text, long gid = 0, string groupName = "")
 {
     WallService.Current.Repost(this.Video.owner_id, this.Video.vid, text, RepostObject.video, gid, delegate(BackendResult <RepostResult, ResultCode> res)
     {
         Execute.ExecuteOnUIThread(delegate
         {
             if (res.ResultCode == ResultCode.Succeeded)
             {
                 GenericInfoUC.ShowPublishResult(GenericInfoUC.PublishedObj.Video, gid, groupName);
                 return;
             }
             new GenericInfoUC().ShowAndHideLater(CommonResources.Error, null);
         });
     });
 }
Exemplo n.º 30
0
 public void RemoveInvitation(LinkHeader item)
 {
     this.SetInProgress(true, "");
     GroupsService.Current.HandleRequest(this.CommunityId, item.Id, false, (Action <BackendResult <int, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
     {
         if (result.ResultCode == ResultCode.Succeeded)
         {
             this.Invitations.Delete(item);
         }
         else
         {
             GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", null);
         }
         this.SetInProgress(false, "");
     }))));
 }