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

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

                return;
            }

            #endregion

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

                Loading = true;

                var result =
                    await
                    _answerService.CancelVoteAsync(LoginUser.Current.Token, AnswerId, LoginUser.Current.Profile.Id);

                Loading = false;

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

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

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

                #endregion
            }
            else
            {
                #region Voteup

                Loading = true;

                var result = await _answerService.VoteUpAsync(LoginUser.Current.Token, AnswerId);

                Loading = false;

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

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

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

                #endregion
            }
        }