Beispiel #1
0
        public async Task UpdatePost()
        {
            var result = await PostApi.GetById(
                SettingsManager.PersistentSettings.CurrentUser.Token,
                CurrentPostData.Id)
                         .ConfigureAwait(true);

            if (result.IsError)
            {
                await DialogManager.ShowErrorDialog(result.Message)
                .ConfigureAwait(true);

                return;
            }

            if (result.Data == null)
            {
                await DialogManager.ShowErrorDialog(result.Message)
                .ConfigureAwait(true);

                return;
            }

            CurrentPostData = result.Data;

            UpdateContextMenus();
        }
        private async void btnViewsBoost_Click(object sender, RoutedEventArgs e)
        {
            btnViewsBoost.IsEnabled = false;

            try
            {
                for (int i = 0; i < Convert.ToInt32(txtViewsCount.Value); ++i)
                {
                    await PostApi.GetById(Convert.ToInt32(txtPostsPostId.Value))
                    .ConfigureAwait(true);
                }

                await DialogManager.ShowDialog("Success", "BOOOOSTED")
                .ConfigureAwait(true);
            }
            catch (Exception ex)
            {
                await DialogManager.ShowDialog("Some rtarded shit happened", ex.Message)
                .ConfigureAwait(true);
            }
            finally
            {
                btnViewsBoost.IsEnabled = true;
            }
        }
        public async Task <PostSchema> GetUpdatedPostData()
        {
            PostSchema postData = null;

            Dispatcher.Invoke(() =>
            {
                postData = ViewModel.CurrentPostData;
            });

            if (postData == null)
            {
                return(postData);
            }

            var result = await PostApi.GetById(
                SettingsManager.PersistentSettings.CurrentUser.Token,
                postData.Id)
                         .ConfigureAwait(true);

            if (result.IsError)
            {
                return(postData);
            }

            return(result.Data ?? postData);
        }
        public async Task UpdatePost(int id)
        {
            if (id < 1)
            {
                if (!NavigationController.Instance.IsCurrentPage <PostOverlayPage>())
                {
                    return;
                }

                NavigationController.Instance.GoBack(true);

                string message = LocalizationUtils.GetLocalized("PostNotFound");

                await DialogManager.ShowErrorDialog(message)
                .ConfigureAwait(true);

                return;
            }

            ViewModel.CurrentPostData.Id = id;

            var result = await PostApi.GetById(
                SettingsManager.PersistentSettings.CurrentUser.Token,
                ViewModel.CurrentPostData.Id)
                         .ConfigureAwait(true);

            if (result.IsError)
            {
                if (!NavigationController.Instance.IsCurrentPage <PostOverlayPage>())
                {
                    return;
                }

                NavigationController.Instance.GoBack(true);

                await DialogManager.ShowErrorDialog(result.Message)
                .ConfigureAwait(true);

                return;
            }

            if (result.Data == null)
            {
                if (!NavigationController.Instance.IsCurrentPage <PostOverlayPage>())
                {
                    return;
                }

                NavigationController.Instance.GoBack(true);

                string message = LocalizationUtils.GetLocalized("PostNotFound");

                await DialogManager.ShowErrorDialog(message)
                .ConfigureAwait(true);

                return;
            }

            ViewModel.CurrentPostData = result.Data;

            wdgPost.UpdateContextMenus();

            if (ViewModel.SourcePostWidget?.CurrentPostData.Id == ViewModel.CurrentPostData.Id)
            {
                ViewModel.SourcePostWidget?.SetValue(
                    PostWidget.CurrentPostDataProperty,
                    ViewModel.CurrentPostData);
            }
        }