示例#1
0
        public async static Task <PostResult> PostNewsVoteAsync(VoteNews voteNews)
        {
            try
            {
                string data = JsonSerializeHelper.Serialize(voteNews);
                string json = await HttpHelper.Post(WcfApiUrlConstants.VoteNews, data, CacheManager.LoginUserInfo.Cookies);

                PostResult response = JsonSerializeHelper.Deserialize <PostResult>(json);
                return(response);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message);
                return(new PostResult()
                {
                    IsSuccess = false, Message = "提交时发送异常"
                });
            }
        }
示例#2
0
        private async void LikeAppBarButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            VoteNews voteNews = new VoteNews();

            voteNews.VoteType = "agree";// voteType == VoteType.Support ? "agree" : "anti";
            voteNews.Id       = NewsBodyViewModel.News.Id;
            var result = await NewsService.PostNewsVoteAsync(voteNews);

            if (!result.IsSuccess)
            {
                MessageDialog messageDialog = new MessageDialog(result.Message);
                await messageDialog.ShowAsync();
            }
            else
            {
                NewsBodyViewModel.News.Diggs++;
                LikeAppBarButton.IsEnabled = false;
            }
        }