Exemplo n.º 1
0
        public async Task GetServiceNews(int pageIndex, int pageSize, int position)
        {
            string url = string.Empty;

            if (position == 0)
            {
                url = string.Format(Constant.NEWS_NEWEST_LIST, pageIndex, pageSize);
            }
            else if (position == 1)
            {
                url = string.Format(Constant.NEWS_HOT_CURRENT_WEEK_LIST, pageIndex, pageSize);
            }
            else
            {
                url = string.Format(Constant.NEWS_HOT_CURRENT_WEEK_LIST, pageIndex, pageSize);
            }
            await HttpClientUtil.GetAsync <List <NewsModel> >(url, null,
                                                              async (list) =>
            {
                newsView.GetServiceNewsSuccess(list);
                if (position == 1)
                {
                    list.ForEach(f => f.IsHot = true);
                }
                else if (position == 2)
                {
                    list.ForEach(f => f.IsDigg = true);
                }
                await SqliteDatabase.Instance().UpdateNewsList(list);
            },
                                                              (error) =>
            {
                newsView.GetServiceNewsFail(error);
            });
        }