예제 #1
0
        private async void VoteUpTappedMethod()
        {
            #region Checking Network

            if (false == Utility.Instance.IsNetworkAvailable)
            {
                ToasteIndicator.Instance.Show(String.Empty, "网络连接已中断", null, 3);

                return;
            }

            #endregion

            if (Detail.Voting == 1)
            {
                #region Cancel Voteup

                Loading = true;

                var result = await _article.CancelVoteUpAsync(LoginUser.Current.Token, _articleId);

                Loading = false;

                if (null != result.Error)
                {
                    ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3);

                    Debug.WriteLine(Regex.Unescape(result.Error.Message));
                    return;
                }

                Detail.Voting      = result.Result.Voting;
                Detail.VoteupCount = result.Result.VoteupCount;

                #endregion
            }
            else
            {
                #region Voteup

                Loading = true;

                var result = await _article.VoteUpAsync(LoginUser.Current.Token, _articleId);

                Loading = false;

                if (null != result.Error)
                {
                    ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3);

                    Debug.WriteLine(Regex.Unescape(result.Error.Message));
                    return;
                }

                Detail.Voting      = result.Result.Voting;
                Detail.VoteupCount = result.Result.VoteupCount;

                #endregion
            }
        }