Пример #1
0
        private async void FollowUnfollowMethod()
        {
            #region Checking Network

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

                return;
            }

            #endregion

            if (null == _questionService || Detail == null ||
                Relationship == null)
            {
                return;
            }

            var questionId = Detail.Id;

            var result = Relationship.IsFollowing == false
                ? await _questionService.FollowAsync(LoginUser.Current.Token, questionId)
                : await _questionService.UnFollowAsync(LoginUser.Current.Token, questionId, LoginUser.Current.Profile.Id);

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

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

                return;
            }

            if (result.Result.IsFollowing)
            {
                Detail.FollowerCount++;
            }
            else
            {
                Detail.FollowerCount--;
            }

            Relationship.IsFollowing = result.Result.IsFollowing;
        }