예제 #1
0
        public async Task <bool> Initialize(string jsonObjectString)
        {
            IsLoading = true;
            long threadId     = 0;
            var  replyManager = new ReplyManager();

            try
            {
                _forumThread = JsonConvert.DeserializeObject <ForumThreadEntity>(jsonObjectString);
            }
            catch (Exception)
            {
                threadId = Convert.ToInt64(jsonObjectString);
            }

            try
            {
                if (_forumThread != null)
                {
                    ForumReplyEntity = await replyManager.GetReplyCookies(_forumThread);
                }
                else
                {
                    ForumReplyEntity = await replyManager.GetReplyCookies(threadId);
                }
            }
            catch (Exception ex)
            {
                ForumReplyEntity = null;
            }
            IsLoading = false;
            return(ForumReplyEntity != null);
        }
        public async override void Execute(object parameter)
        {
            var args = parameter as RoutedEventArgs;
            if (args == null)
            {
                await AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));
                return;
            }

            var appButton = args.OriginalSource as AppBarButton;
            var vm = appButton?.DataContext as ThreadPageViewModel;

            if (vm == null)
                return;

            Locator.ViewModels.NewThreadReplyVm.PostBody = string.Empty;
            Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity;
            App.RootFrame.Navigate(typeof(NewThreadReplyPage));
            Locator.ViewModels.NewThreadReplyVm.IsLoading = true;
            try
            {
                var replyManager = new ReplyManager();
                Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity =
                    await replyManager.GetReplyCookies(Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity);
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex);
                App.RootFrame.GoBack();
            }


            Locator.ViewModels.NewThreadReplyVm.IsLoading = false;
        }
예제 #3
0
        public async override void Execute(object parameter)
        {
            long id = long.Parse((string)parameter);
            var  vm = Locator.ViewModels.ThreadPageVm;

            if (vm == null)
            {
                return;
            }
            Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity;

            App.RootFrame.Navigate(typeof(NewThreadReplyPage));
            Locator.ViewModels.NewThreadReplyVm.IsLoading = true;
            try
            {
                var replyManager = new ReplyManager();
                Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity =
                    await replyManager.GetReplyCookies(id);

                Locator.ViewModels.NewThreadReplyVm.PostBody =
                    Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote;
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex);
                App.RootFrame.GoBack();
            }
            Locator.ViewModels.NewThreadReplyVm.IsLoading = false;
        }
예제 #4
0
        public async override void Execute(object parameter)
        {
            var args = parameter as RoutedEventArgs;

            if (args == null)
            {
                await AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null"));

                return;
            }

            var appButton = args.OriginalSource as AppBarButton;
            var vm        = appButton?.DataContext as ThreadPageViewModel;

            if (vm == null)
            {
                return;
            }

            Locator.ViewModels.NewThreadReplyVm.PostBody          = string.Empty;
            Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity;
            App.RootFrame.Navigate(typeof(NewThreadReplyPage));
            Locator.ViewModels.NewThreadReplyVm.IsLoading = true;
            try
            {
                var replyManager = new ReplyManager();
                Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity =
                    await replyManager.GetReplyCookies(Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity);
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex);
                App.RootFrame.GoBack();
            }


            Locator.ViewModels.NewThreadReplyVm.IsLoading = false;
        }
        public async override void Execute(object parameter)
        {
            long id = long.Parse((string)parameter);
            var vm = Locator.ViewModels.ThreadPageVm;

            if (vm == null)
                return;
            Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity;

            App.RootFrame.Navigate(typeof(NewThreadReplyPage));
            Locator.ViewModels.NewThreadReplyVm.IsLoading = true;
            try
            {
                var replyManager = new ReplyManager();
                Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity =
                    await replyManager.GetReplyCookies(id);
                Locator.ViewModels.NewThreadReplyVm.PostBody =
                    Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote;
            }
            catch (Exception ex)
            {
                AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex);
                App.RootFrame.GoBack();
            }
            Locator.ViewModels.NewThreadReplyVm.IsLoading = false;
        }