static void Main(string[] args) { UsersList usersList = new UsersList(); User newUser = usersList.CreateAccount(); PostsList postsList = new PostsList(); int option; do { Console.WriteLine("What do you want to do?"); Console.WriteLine("0 - Exit"); Console.WriteLine("1 - Create posts"); Console.WriteLine("2 - Display posts"); int.TryParse(Console.ReadLine(), out option); switch (option) { case 0: break; case 1: Post newPost = postsList.CreatePost(newUser); break; case 2: postsList.DisplayPosts(); break; default: break; } } while (option != 0); }
public async Task Filter(string Title) { try { var postSearch = await _postsService.Get <IList <PostModel> >(new PostSearchRequest { Title = Title }, "search"); PostsList.Clear(); foreach (var item in postSearch) { PostsList.Add(item); item.Comments = new ObservableCollection <CommentDto>(); var comments = await _commentsService.Get <IList <CommentDto> >(null, $"posts/{item.Id}"); comments.ForEach(x => { item.Comments.Add(x); }); } } catch (Exception) { throw; } }
async void DoPostCommand() { if (CircleID != Constants.NoSelection) { try { Post toAdd = new Post { text = NewPost, user_id = UserID, circle_id = CircleID, created_at = DateTime.UtcNow, updated_at = DateTime.UtcNow }; await _mLearningService.CreateObject <Post>(toAdd, p => p.id); NewPost = ""; post_with_username puser = new post_with_username(toAdd); puser.username = SessionService.GetUsername(); PostsList.Add(new post_with_username_wrapper { post = puser, userImage = UserImage }); } catch (WebException e) { ConnectionOK = false; } } else { //Notify Invalid Operation OperationOK = false; } }
public async Task Init() { try { PostsList.Clear(); IList <PostModel> posts = null; if (!_blog) { posts = await _postsService.Get <IList <PostModel> >(); } else { posts = await _postsService.Get <IList <PostModel> >(null, "followed"); } foreach (var item in posts) { //item.Comments = await _commentsService.Get<IList<CommentDto>>(null, $"posts/{item.Id}"); var data = await _commentsService.Get <IList <CommentDto> >(null, $"posts/{item.Id}"); item.Comments = new ObservableCollection <CommentDto>(data); PostsList.Add(item); } } catch { throw; } }
/// <summary> /// Run the tally using the provided posts, for the selected quest. /// </summary> /// <param name="posts">The posts to be tallied.</param> /// <param name="quest">The quest being tallied.</param> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(IEnumerable <PostComponents> posts, IQuest quest, CancellationToken token) { Quest = quest; PostsList.Clear(); PostsList.AddRange(posts); await TallyPosts(token).ConfigureAwait(false); }
public async Task <PostsList <Post> > GetPostsList(PostsListParams postsListParams) { var posts = context.Posts .OrderByDescending(o => o.DateAdded) .AsQueryable(); return(await PostsList <Post> .CreateAsync(posts, postsListParams.PartNumber, postsListParams.PartSize)); }
public override void OnCreate(Bundle savedInstanceState) { prefs = PreferenceManager.GetDefaultSharedPreferences(Activity.ApplicationContext); var host = prefs.GetString("host", null); _manager = new ApiManager(host); postsList = new PostsList(new List <Model.Post>()); base.OnCreate(savedInstanceState); }
/// <summary> /// Run the tally using the provided posts, for the selected quest. /// </summary> /// <param name="posts">The posts to be tallied.</param> /// <param name="quest">The quest being tallied.</param> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(IEnumerable <PostComponents> posts, IQuest quest, CancellationToken token) { Quest = quest; PostsList.Clear(); PostsList.AddRange(posts); await TallyPosts(token).ConfigureAwait(false); OrderedTaskList.AddRange(ViewModelService.MainViewModel.KnownTasks); OnPropertyChanged("Tasks"); }
async Task UpdateUserPostImages(int index) { //_post_image_manager.TryLoadByteVector<post_with_username_wrapper>(index, PostsList.ToList() // , (pos, bytes) => // { // PostsList[pos].userImage = bytes; // } // , (post) => // { // return post.post.image_url; // }); await BlockDownload.TryPutBytesInVector <post_with_username_wrapper>(PostsList.ToList(), (pos, bytes) => { if (pos < PostsList.Count) { PostsList[pos].userImage = bytes; } } , (post) => { return(post.post.image_url); }); }
/// <summary> /// Wraps the returning posts into Post objects. Uses JSON.net for deserialization /// </summary> /// <param name="site">the site url. insert without http:// prefix</param> /// <param name="type">the type of posts that shall be returned (post or page)</param> /// <param name="status">the status of posts that shall be returned</param> /// <param name="number">the number of posts that shall be returned</param> /// <param name="offset">the 0-indexed offset for the request. Default value goes to 0. Use this parameter for pagination.</param> /// <returns>List of all posts that matching the query</returns> public async Task <PostsList> GetPostList(string site, PostType type, PostStatus status, int?number = null, int?offset = null) { PostsList post_list = new PostsList(); var response = await getPosts(site, type, status, number, offset); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var responseString = await response.Content.ReadAsStringAsync(); post_list = JsonConvert.DeserializeObject <PostsList>(responseString); if (post_list.posts_total_count != 0) { foreach (var item in post_list.posts_list) { //getting categories as string but handled as object to keep deserializing of posts possible if (item.categories != null) { var cat_object = item.categories; item.categories = PostCategories.GetString(cat_object); } //getting tags as string but handled as object to keep deserializing of posts possible if (item.tags != null) { var tags_object = item.tags; item.tags = PostTags.GetString(tags_object); } //getting attachments as List but handled as object to keep deserializing of posts possible if (item.attachments != null) { var attachments_obj = item.attachments; item.attachments = PostAttachments.GetList(attachments_obj); } //getting metadata as List but handled as object to keep deserializing of posts possible if (item.metadata != null) { var metadata_obj = item.metadata; item.metadata = PostMetaData.GetList(metadata_obj); } } } else { Debug.WriteLine("WARNING: GetPostList returned 0 results. Wrong parameters?"); } } else if (response.StatusCode != System.Net.HttpStatusCode.OK) { var responseString = await response.Content.ReadAsStringAsync(); var Error = JsonConvert.DeserializeObject <apiError>(responseString); Debug.WriteLine(string.Format("ERROR on GetPostList: The site returned: {0}. JetPack not installed on WordPress or JetPack JSON API not active?", Error.message)); } return(post_list); }