/// <summary> /// Implemeted only online lookup /// </summary> /// <param name="category"></param> /// <param name="numberOfPosts"></param> /// <param name="page"></param> /// <returns></returns> public static async Task<ModelWrapper<List<Post>>> GetPostsOnline(PostRequest postRequest) { // check internet connection if (!ConnectionInfo.InternetConnected()) { return new ModelWrapper<List<Post>>(TaskResult.NoInternet); } // get posts online try { using (HttpClient httpClient = new HttpClient()) { string postsData = await httpClient.GetStringAsync(postRequest.GetUri()); List<Post> tempList = JsonConvert.DeserializeObject<List<Post>>(postsData); if (tempList != null && tempList.Count > 0) { if (postRequest.SaveRequired) { // successfully retrieve posts, so save them DataManager.SavePosts(tempList, postRequest.CurrentCategory, postRequest.CurrentOffset); } return new ModelWrapper<List<Post>>(tempList, TaskResult.Success); } else { return new ModelWrapper<List<Post>>(TaskResult.NoData); } } } catch (Exception) { return new ModelWrapper<List<Post>>(TaskResult.Error); } }