Esempio n. 1
0
        private async void CheckUnreadFollowsMethod()
        {
            if (null == _notify)
            {
                return;
            }

            FollowsVisible = Visibility.Collapsed;

            var result = await _notify.CheckFollowsAsync(LoginUser.Current.Token, "notifications/unread_follows", true);

            ContentsLoading = false;

            if (result == null)
            {
                return;
            }

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

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

                return;
            }

            Follows.Clear();
            foreach (var item in result.Result.GetItems().Select(item => item as NotifyItem))
            {
                Follows.Add(item);
            }

            FollowsVisible = Follows.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
        }
Esempio n. 2
0
        /// <summary>FollowedUsersResponse constructor</summary>
        /// <param name="apiResponse">Returned api response in string form.</param>
        public FollowedUsersResponse(string apiResponse)
        {
            JObject json = JObject.Parse(apiResponse);

            foreach (JToken followedUser in json.SelectToken("follows"))
            {
                Follows.Add(new Follow(followedUser.ToString()));
            }
            TotalFollowCount = int.Parse(json.SelectToken("_total").ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Método para fazer a verificação e inserção do terminal
        /// </summary>
        /// <param name="terminal"></param>
        /// <returns></returns>
        public bool AddTerminalToFollow(Terminal terminal)
        {
            string value = terminal.Value;

            if (!FollowList.ContainsKey(value))
            {
                FollowList.Add(value, true);
                Follows.Add(terminal);

                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public Follow AddFollow(int followerId, int followedId)
        {
            var follow = Follows.SingleOrDefault(f => f.FollowerId == followerId && f.FollowedId == followedId);

            if (follow != null)
            {
                return(follow);
            }
            var follower = GetUserById(followerId);
            var followed = GetUserById(followedId);

            follow          = new Follow();
            follow.Follower = follower;
            follow.Followed = followed;
            Follows.Add(follow);
            SaveChanges();
            return(follow);
        }
Esempio n. 5
0
        public async Task LoadFollows()
        {
            try
            {
                Loading      = true;
                Nothing      = false;
                ShowLoadMore = false;
                var api = followAPI.MyFollowBangumi(page: Page, status: Status);
                if (!isAnime)
                {
                    api = followAPI.MyFollowCinema(page: Page, status: Status);
                }
                var results = await api.Request();

                if (results.status)
                {
                    var data = await results.GetJson <ApiResultModel <JObject> >();

                    if (data.success)
                    {
                        if (data.result["has_next"].ToInt32() == 1)
                        {
                            ShowLoadMore = true;
                        }
                        if (!data.result.ContainsKey("follow_list"))
                        {
                            if (Page == 1)
                            {
                                Nothing = true;
                                Follows = new ObservableCollection <FollowSeasonModel>();
                            }
                            else
                            {
                                Utils.ShowMessageToast("全部加载完了...");
                            }
                            return;
                        }
                        var ls = await data.result["follow_list"].ToString().DeserializeJson <ObservableCollection <FollowSeasonModel> >();
                        if (ls != null && ls.Count != 0)
                        {
                            foreach (var item in ls)
                            {
                                item.status = Status;
                                item.CancelFollowCommand = CancelFollowCommand;
                                item.SetWantWatchCommand = SetWantWatchCommand;
                                item.SetWatchedCommand   = SetWatchedCommand;
                                item.SetWatchingCommand  = SetWatchingCommand;
                            }
                            if (Page == 1)
                            {
                                Follows = ls;
                            }
                            else
                            {
                                foreach (var item in ls)
                                {
                                    Follows.Add(item);
                                }
                            }
                            Page++;
                        }
                    }
                    else
                    {
                        Utils.ShowMessageToast(data.message);
                    }
                }
                else
                {
                    Utils.ShowMessageToast(results.message);
                }
            }
            catch (Exception ex)
            {
                var handel = HandelError <AnimeHomeModel>(ex);
                Utils.ShowMessageToast(handel.message);
            }
            finally
            {
                Loading = false;
            }
        }