public Task <ResponseListPost> GetRecentPosts(RequestRecentPosts request) { var response = CallService <ResponseListPost, RequestRecentPosts>(Settings.GetRecentPostsUrl, HttpMethod.Post, request); return(response); }
async public void LoadData(int id, int page = 1) { if (Status == NetworkStatus.NotReachable) {//true || ShowErrorMessage (Settings.MSG_NETWORK_NOT_REACHABLE); return; } RequestBase req = null; if (Settings.USE_RECENT_POSTS && id == Settings.RECENT_POST_CATEGORY_ID) { req = new RequestRecentPosts (); ((RequestRecentPosts)req).Page = page; } else { req = new RequestCategoryPosts (); ((RequestCategoryPosts)req).Id = id; ((RequestCategoryPosts)req).Page = page; } IsLoading = true; ResponseListPost resPosts = null; try{ if (req.GetType () == typeof(RequestRecentPosts)) { resPosts = await Service.GetRecentPosts ((RequestRecentPosts)req); } else { resPosts = await Service.GetCategoryPosts ((RequestCategoryPosts)req); } mPages = resPosts.Pages; //ListPost.Clear (); var pas = resPosts.Posts.ToArray (); for (int i = 0; i < pas.Length; i++) { Add (pas [i], true); //check exist when update list //ListPost.Add(pas [i]); } HasMorePage = (mCurrentPage < mPages); RaisePropertyChanged("ListPost"); } catch (Exception e){ ShowErrorMessage (Settings.MSG_NETWORK_COMMON, e); } IsLoading = false; }