/// <summary>
        /// Post status in facebook wall
        /// </summary>
        /// <param name="i_Sender">Object sender</param>
        /// <param name="i_Event">The event</param>
        private void buttonPost_Click(object i_Sender, EventArgs i_Event)
        {
            Status postedStatus = r_LoggedInUser.PostStatus(postTextBox.Text);
            MyPost newPost      = new MyPost(postTextBox.Text);

            m_MyPosts.Add(newPost);
            listBoxFeed.Invoke(new Action(() => listBoxFeed.Refresh()));
            MessageBox.Show(string.Format(@"Status: {0} Posted", postedStatus.Message));
        }
示例#2
0
        public void Add()
        {
            using (var api = new Api(GetDb(), storage, cache)) {
                var count = api.Posts.GetAll(BLOG_ID).Count();
                var post  = MyPost.Create(api, "MyPost");
                post.BlogId     = BLOG_ID;
                post.CategoryId = CAT_1_ID;
                post.Title      = "My fourth post";
                post.Ingress    = "My fourth ingress";
                post.Body       = "My fourth body";

                api.Posts.Save(post);

                Assert.Equal(count + 1, api.Posts.GetAll(BLOG_ID).Count());
            }
        }
示例#3
0
        public async Task AddDuplicateSlugShouldThrow()
        {
            using (var api = CreateApi())
            {
                var post = await MyPost.CreateAsync(api);

                post.BlogId    = BLOG_ID;
                post.Title     = "My first post";
                post.Published = DateTime.Now;

                await Assert.ThrowsAsync <ValidationException>(async() =>
                {
                    await api.Posts.SaveAsync(post);
                });
            }
        }
示例#4
0
 protected override void ShowPage()
 {
     this.pagetitle = "用户控制面板";
     if (this.userid == -1)
     {
         base.AddErrLine("你尚未登录");
         return;
     }
     this.user = Users.GetUserInfo(this.userid);
     //this.topiccount = Topics.GetTopicsCountbyUserId(this.userid, true);
     this.topiccount  = MyPost.FindTidCountByUid(userid);
     this.pagecount   = ((this.topiccount % 16 == 0) ? (this.topiccount / 16) : (this.topiccount / 16 + 1));
     this.pagecount   = ((this.pagecount == 0) ? 1 : this.pagecount);
     this.pageid      = ((this.pageid < 1) ? 1 : this.pageid);
     this.pageid      = ((this.pageid > this.pagecount) ? this.pagecount : this.pageid);
     this.topics      = Topics.GetTopicsByReplyUserId(this.userid, this.pageid, 16, 600, this.config.Hottopic);
     this.pagenumbers = Utils.GetPageNumbers(this.pageid, this.pagecount, "myposts.aspx", 8);
 }
示例#5
0
        public void Add()
        {
            using (var api = CreateApi()) {
                var count    = api.Posts.GetAll(BLOG_ID).Count();
                var catCount = api.Posts.GetAllCategories(BLOG_ID).Count();
                var post     = MyPost.Create(api, "MyPost");
                post.BlogId   = BLOG_ID;
                post.Category = "My category";
                post.Title    = "My fourth post";
                post.Ingress  = "My fourth ingress";
                post.Body     = "My fourth body";

                api.Posts.Save(post);

                Assert.Equal(count + 1, api.Posts.GetAll(BLOG_ID).Count());
                Assert.Equal(catCount, api.Posts.GetAllCategories(BLOG_ID).Count());
            }
        }
示例#6
0
        public async Task Add()
        {
            using (var api = CreateApi())
            {
                var count    = (await api.Posts.GetAllAsync(BLOG_ID)).Count();
                var catCount = (await api.Posts.GetAllCategoriesAsync(BLOG_ID)).Count();
                var post     = await MyPost.CreateAsync(api, "MyPost");

                post.BlogId   = BLOG_ID;
                post.Category = "My category";
                post.Title    = "My fourth post";
                post.Ingress  = "My fourth ingress";
                post.Body     = "My fourth body";

                await api.Posts.SaveAsync(post);

                Assert.Equal(count + 1, (await api.Posts.GetAllAsync(BLOG_ID)).Count());
                Assert.Equal(catCount, (await api.Posts.GetAllCategoriesAsync(BLOG_ID)).Count());
            }
        }
示例#7
0
        public async Task AddWithTags()
        {
            using (var api = CreateApi())
            {
                var count    = (await api.Posts.GetAllAsync(BLOG_ID)).Count();
                var catCount = (await api.Posts.GetAllCategoriesAsync(BLOG_ID)).Count();
                var tagCount = (await api.Posts.GetAllTagsAsync(BLOG_ID)).Count();

                var post = await MyPost.CreateAsync(api, "MyPost");

                post.BlogId   = BLOG_ID;
                post.Category = "My category";
                post.Tags.Add("Testing", "Trying", "Adding");
                post.Title   = "My fifth post";
                post.Ingress = "My fifth ingress";
                post.Body    = "My fifth body";

                await api.Posts.SaveAsync(post);

                Assert.Equal(count + 1, (await api.Posts.GetAllAsync(BLOG_ID)).Count());
                Assert.Equal(catCount, (await api.Posts.GetAllCategoriesAsync(BLOG_ID)).Count());
                Assert.Equal(tagCount + 3, (await api.Posts.GetAllTagsAsync(BLOG_ID)).Count());

                post = await api.Posts.GetBySlugAsync <MyPost>(BLOG_ID, Piranha.Utils.GenerateSlug("My fifth post"));

                Assert.NotNull(post);
                Assert.Equal(3, post.Tags.Count);
                post.Tags.Add("Another tag");

                await api.Posts.SaveAsync(post);

                Assert.Equal(tagCount + 4, (await api.Posts.GetAllTagsAsync(BLOG_ID)).Count());

                post = await api.Posts.GetBySlugAsync <MyPost>(BLOG_ID, Piranha.Utils.GenerateSlug("My fifth post"));

                Assert.NotNull(post);
                Assert.Equal(4, post.Tags.Count);
            }
        }
示例#8
0
        public void AddWithTags()
        {
            using (var api = new Api(GetDb(), storage, cache)) {
                var count    = api.Posts.GetAll(BLOG_ID).Count();
                var catCount = api.Categories.GetAll(BLOG_ID).Count();
                var tagCount = api.Tags.GetAll(BLOG_ID).Count();

                var post = MyPost.Create(api, "MyPost");
                post.BlogId   = BLOG_ID;
                post.Category = "My category";
                post.Tags.Add("Testing", "Trying", "Adding");
                post.Title   = "My fifth post";
                post.Ingress = "My fifth ingress";
                post.Body    = "My fifth body";

                api.Posts.Save(post);

                Assert.Equal(count + 1, api.Posts.GetAll(BLOG_ID).Count());
                Assert.Equal(catCount, api.Categories.GetAll(BLOG_ID).Count());
                Assert.Equal(tagCount + 3, api.Tags.GetAll(BLOG_ID).Count());

                post = api.Posts.GetBySlug <MyPost>(BLOG_ID, Piranha.Utils.GenerateSlug("My fifth post"));

                Assert.NotNull(post);
                Assert.Equal(3, post.Tags.Count);
                post.Tags.Add("Another tag");

                api.Posts.Save(post);

                Assert.Equal(tagCount + 4, api.Tags.GetAll(BLOG_ID).Count());

                post = api.Posts.GetBySlug <MyPost>(BLOG_ID, Piranha.Utils.GenerateSlug("My fifth post"));

                Assert.NotNull(post);
                Assert.Equal(4, post.Tags.Count);
            }
        }
示例#9
0
        protected override void Init()
        {
            using (var api = new Api(GetDb(), storage, cache)) {
                Piranha.App.Init(api);

                var pageTypeBuilder = new PageTypeBuilder(api)
                                      .AddType(typeof(BlogPage));
                pageTypeBuilder.Build();
                var postTypeBuilder = new PostTypeBuilder(api)
                                      .AddType(typeof(MissingPost))
                                      .AddType(typeof(MyPost))
                                      .AddType(typeof(MyCollectionPost));
                postTypeBuilder.Build();

                // Add site
                var site = new Data.Site()
                {
                    Id         = SITE_ID,
                    Title      = "Post Site",
                    InternalId = "PostSite",
                    IsDefault  = true
                };
                api.Sites.Save(site);

                // Add blog page
                var page = BlogPage.Create(api);
                page.Id     = BLOG_ID;
                page.SiteId = SITE_ID;
                page.Title  = "Blog";
                api.Pages.Save(page);

                var category = new Data.Category()
                {
                    Id     = CAT_1_ID,
                    BlogId = BLOG_ID,
                    Title  = "My category"
                };
                api.Categories.Save(category);

                var post1 = MyPost.Create(api);
                post1.Id       = POST_1_ID;
                post1.BlogId   = BLOG_ID;
                post1.Category = category;
                post1.Title    = "My first post";
                post1.Ingress  = "My first ingress";
                post1.Body     = "My first body";
                api.Posts.Save(post1);

                var post2 = MyPost.Create(api);
                post2.Id       = POST_2_ID;
                post2.BlogId   = BLOG_ID;
                post2.Category = category;
                post2.Title    = "My second post";
                post2.Ingress  = "My second ingress";
                post2.Body     = "My second body";
                api.Posts.Save(post2);

                var post3 = MyPost.Create(api);
                post3.Id       = POST_3_ID;
                post3.BlogId   = BLOG_ID;
                post3.Category = category;
                post3.Title    = "My third post";
                post3.Ingress  = "My third ingress";
                post3.Body     = "My third body";
                api.Posts.Save(post3);

                var post4 = MyCollectionPost.Create(api);
                post4.BlogId   = BLOG_ID;
                post4.Category = category;
                post4.Title    = "My collection post";
                post4.Texts.Add(new TextField()
                {
                    Value = "First text"
                });
                post4.Texts.Add(new TextField()
                {
                    Value = "Second text"
                });
                post4.Texts.Add(new TextField()
                {
                    Value = "Third text"
                });
                api.Posts.Save(post4);
            }
        }
示例#10
0
        protected override void Init()
        {
            using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage)) {
                Piranha.App.Init(api);

                var pageBuilder = new PageTypeBuilder(api)
                                  .AddType(typeof(MyPage));
                pageBuilder.Build();

                var postBuilder = new PostTypeBuilder(api)
                                  .AddType(typeof(MyPost));
                postBuilder.Build();

                // Add site
                var site1 = new Data.Site()
                {
                    Id         = SITE1_ID,
                    Title      = "Page Site",
                    InternalId = "PostSite",
                    IsDefault  = true
                };
                api.Sites.Save(site1);

                var site2 = new Data.Site()
                {
                    Id         = SITE2_ID,
                    Title      = "Page Site 2",
                    InternalId = "PostSite2",
                    Hostnames  = "www.myothersite.com",
                    IsDefault  = false
                };
                api.Sites.Save(site2);

                // Add pages
                var page1 = MyPage.Create(api);
                page1.Id        = PAGE1_ID;
                page1.SiteId    = SITE1_ID;
                page1.Title     = "Blog";
                page1.Published = DateTime.Now;
                api.Pages.Save(page1);

                var page2 = MyPage.Create(api);
                page2.Id        = PAGE2_ID;
                page2.SiteId    = SITE2_ID;
                page2.Title     = "News";
                page2.Published = DateTime.Now;
                api.Pages.Save(page2);

                // Add categories
                var category1 = new Data.Category()
                {
                    Id     = CATEGORY1_ID,
                    BlogId = PAGE1_ID,
                    Title  = "Default category"
                };
                api.Categories.Save(category1);

                var category2 = new Data.Category()
                {
                    Id     = CATEGORY2_ID,
                    BlogId = PAGE2_ID,
                    Title  = "Default category"
                };
                api.Categories.Save(category2);

                // Add tags
                var tag = new Data.Tag()
                {
                    Id     = TAG1_ID,
                    BlogId = PAGE1_ID,
                    Title  = "My tag"
                };
                api.Tags.Save(tag);

                tag = new Data.Tag()
                {
                    Id     = TAG2_ID,
                    BlogId = PAGE2_ID,
                    Title  = "My other tag"
                };
                api.Tags.Save(tag);

                // Add posts
                var post1 = MyPost.Create(api);
                post1.Id       = POST1_ID;
                post1.BlogId   = page1.Id;
                post1.Category = category1;
                post1.Title    = "My first post";
                post1.Body     = "My first body";
                post1.Tags.Add("My tag");
                post1.Published = DateTime.Now;
                api.Posts.Save(post1);

                var post2 = MyPost.Create(api);
                post2.Id       = POST2_ID;
                post2.BlogId   = page2.Id;
                post2.Category = category2;
                post2.Title    = "My second post";
                post2.Body     = "My second body";
                post2.Tags.Add("My other tag");
                post2.Published = DateTime.Now;
                api.Posts.Save(post2);
            }
        }
示例#11
0
        protected override void Init()
        {
            services = new ServiceCollection()
                       .AddSingleton <IMyService, MyService>()
                       .BuildServiceProvider();

            using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) {
                Piranha.App.Init();

                Piranha.App.Fields.Register <MyFourthField>();

                var pageTypeBuilder = new PageTypeBuilder(api)
                                      .AddType(typeof(BlogPage));
                pageTypeBuilder.Build();
                var postTypeBuilder = new PostTypeBuilder(api)
                                      .AddType(typeof(MissingPost))
                                      .AddType(typeof(MyPost))
                                      .AddType(typeof(MyCollectionPost))
                                      .AddType(typeof(MyDIPost));
                postTypeBuilder.Build();

                // Add site
                var site = new Data.Site()
                {
                    Id         = SITE_ID,
                    Title      = "Post Site",
                    InternalId = "PostSite",
                    IsDefault  = true
                };
                api.Sites.Save(site);

                // Add blog page
                var page = BlogPage.Create(api);
                page.Id     = BLOG_ID;
                page.SiteId = SITE_ID;
                page.Title  = "Blog";
                api.Pages.Save(page);

                var category = new Data.Category()
                {
                    Id     = CAT_1_ID,
                    BlogId = BLOG_ID,
                    Title  = "My category"
                };
                api.Categories.Save(category);

                var post1 = MyPost.Create(api);
                post1.Id       = POST_1_ID;
                post1.BlogId   = BLOG_ID;
                post1.Category = category;
                post1.Title    = "My first post";
                post1.Ingress  = "My first ingress";
                post1.Body     = "My first body";
                post1.Blocks.Add(new Extend.Blocks.TextBlock {
                    Body = "Sollicitudin Aenean"
                });
                post1.Blocks.Add(new Extend.Blocks.TextBlock {
                    Body = "Ipsum Elit"
                });
                api.Posts.Save(post1);

                var post2 = MyPost.Create(api);
                post2.Id       = POST_2_ID;
                post2.BlogId   = BLOG_ID;
                post2.Category = category;
                post2.Title    = "My second post";
                post2.Ingress  = "My second ingress";
                post2.Body     = "My second body";
                api.Posts.Save(post2);

                var post3 = MyPost.Create(api);
                post3.Id       = POST_3_ID;
                post3.BlogId   = BLOG_ID;
                post3.Category = category;
                post3.Title    = "My third post";
                post3.Ingress  = "My third ingress";
                post3.Body     = "My third body";
                api.Posts.Save(post3);

                var post4 = MyCollectionPost.Create(api);
                post4.BlogId   = BLOG_ID;
                post4.Category = category;
                post4.Title    = "My collection post";
                post4.Texts.Add(new TextField()
                {
                    Value = "First text"
                });
                post4.Texts.Add(new TextField()
                {
                    Value = "Second text"
                });
                post4.Texts.Add(new TextField()
                {
                    Value = "Third text"
                });
                api.Posts.Save(post4);

                var post6 = MyDIPost.Create(api);
                post6.Id       = POST_DI_ID;
                post6.BlogId   = BLOG_ID;
                post6.Category = category;
                post6.Title    = "My Injection Post";
                api.Posts.Save(post6);
            }
        }
示例#12
0
        public override async Task InitializeAsync()
        {
            using (var api = CreateApi())
            {
                Piranha.App.Init(api);

                var pageBuilder = new PageTypeBuilder(api)
                                  .AddType(typeof(MyPage));
                pageBuilder.Build();

                var postBuilder = new PostTypeBuilder(api)
                                  .AddType(typeof(MyPost));
                postBuilder.Build();

                // Add site
                var site1 = new Site
                {
                    Id         = SITE1_ID,
                    Title      = "Page Site",
                    InternalId = "PostSite",
                    IsDefault  = true
                };
                await api.Sites.SaveAsync(site1);

                var site2 = new Site
                {
                    Id         = SITE2_ID,
                    Title      = "Page Site 2",
                    InternalId = "PostSite2",
                    Hostnames  = "www.myothersite.com",
                    IsDefault  = false
                };
                await api.Sites.SaveAsync(site2);

                // Add pages
                var page1 = await MyPage.CreateAsync(api);

                page1.Id        = PAGE1_ID;
                page1.SiteId    = SITE1_ID;
                page1.Title     = "Blog";
                page1.Published = DateTime.Now;
                await api.Pages.SaveAsync(page1);

                var page2 = await MyPage.CreateAsync(api);

                page2.Id        = PAGE2_ID;
                page2.SiteId    = SITE2_ID;
                page2.Title     = "News";
                page2.Published = DateTime.Now;
                await api.Pages.SaveAsync(page2);

                // Add categories
                var category1 = new Models.Taxonomy
                {
                    Id    = CATEGORY1_ID,
                    Title = "Default category"
                };

                var category2 = new Models.Taxonomy
                {
                    Id    = CATEGORY2_ID,
                    Title = "Default category"
                };

                // Add posts
                var post1 = await MyPost.CreateAsync(api);

                post1.Id       = POST1_ID;
                post1.BlogId   = page1.Id;
                post1.Category = category1;
                post1.Title    = "My first post";
                post1.Body     = "My first body";
                post1.Tags.Add(new Models.Taxonomy
                {
                    Id    = TAG1_ID,
                    Title = "My tag"
                });
                post1.Published = DateTime.Now;
                await api.Posts.SaveAsync(post1);

                var post2 = await MyPost.CreateAsync(api);

                post2.Id       = POST2_ID;
                post2.BlogId   = page2.Id;
                post2.Category = category2;
                post2.Title    = "My second post";
                post2.Body     = "My second body";
                post2.Tags.Add(new Models.Taxonomy
                {
                    Id    = TAG2_ID,
                    Title = "My other tag"
                });
                post2.Published = DateTime.Now;
                await api.Posts.SaveAsync(post2);
            }
        }
示例#13
0
        public override async Task InitializeAsync()
        {
            _services = new ServiceCollection()
                        .AddSingleton <IMyService, MyService>()
                        .BuildServiceProvider();

            using (var api = CreateApi())
            {
                Piranha.App.Init(api);

                Piranha.App.Fields.Register <MyFourthField>();

                var pageTypeBuilder = new PageTypeBuilder(api)
                                      .AddType(typeof(BlogPage));
                pageTypeBuilder.Build();
                var postTypeBuilder = new PostTypeBuilder(api)
                                      .AddType(typeof(MissingPost))
                                      .AddType(typeof(MyPost))
                                      .AddType(typeof(MyCollectionPost))
                                      .AddType(typeof(MyDIPost));
                postTypeBuilder.Build();

                // Add site
                var site = new Site
                {
                    Id         = SITE_ID,
                    Title      = "Post Site",
                    InternalId = "PostSite",
                    IsDefault  = true
                };
                await api.Sites.SaveAsync(site);

                // Add blog page
                var page = await BlogPage.CreateAsync(api);

                page.Id     = BLOG_ID;
                page.SiteId = SITE_ID;
                page.Title  = "Blog";
                await api.Pages.SaveAsync(page);

                var category = new Models.Taxonomy
                {
                    Id    = CAT_1_ID,
                    Title = "My category"
                };

                var post1 = await MyPost.CreateAsync(api);

                post1.Id       = POST_1_ID;
                post1.BlogId   = BLOG_ID;
                post1.Category = category;
                post1.Title    = "My first post";
                post1.Ingress  = "My first ingress";
                post1.Body     = "My first body";
                post1.Blocks.Add(new Extend.Blocks.TextBlock
                {
                    Body = "Sollicitudin Aenean"
                });
                post1.Blocks.Add(new Extend.Blocks.TextBlock
                {
                    Body = "Ipsum Elit"
                });
                await api.Posts.SaveAsync(post1);

                var post2 = await MyPost.CreateAsync(api);

                post2.Id       = POST_2_ID;
                post2.BlogId   = BLOG_ID;
                post2.Category = category;
                post2.Title    = "My second post";
                post2.Ingress  = "My second ingress";
                post2.Body     = "My second body";
                await api.Posts.SaveAsync(post2);

                var post3 = await MyPost.CreateAsync(api);

                post3.Id       = POST_3_ID;
                post3.BlogId   = BLOG_ID;
                post3.Category = category;
                post3.Title    = "My third post";
                post3.Ingress  = "My third ingress";
                post3.Body     = "My third body";
                await api.Posts.SaveAsync(post3);

                var post4 = await MyCollectionPost.CreateAsync(api);

                post4.BlogId   = BLOG_ID;
                post4.Category = category;
                post4.Title    = "My collection post";
                post4.Texts.Add(new TextField
                {
                    Value = "First text"
                });
                post4.Texts.Add(new TextField
                {
                    Value = "Second text"
                });
                post4.Texts.Add(new TextField
                {
                    Value = "Third text"
                });
                await api.Posts.SaveAsync(post4);

                var post6 = await MyDIPost.CreateAsync(api);

                post6.Id       = POST_DI_ID;
                post6.BlogId   = BLOG_ID;
                post6.Category = category;
                post6.Title    = "My Injection Post";
                await api.Posts.SaveAsync(post6);
            }
        }
        static void Main(string[] args)
        {
            int    op         = -1;
            int    IdPostagem = 0;
            MyPost myPost     = new MyPost();

            while (op != 0)
            {
                Console.Clear();
                Console.WriteLine("=============================================");
                Console.WriteLine("                    My Posts                 ");
                Console.WriteLine("=============================================");
                Console.WriteLine("");
                Console.WriteLine("(1) - Listar minhas postagem...");
                Console.WriteLine("(2) - Criar nova postagem...");
                Console.WriteLine("(3) - Curtir postagem...");
                Console.WriteLine("(4) - Comentar postagem...");
                Console.WriteLine("(0) - Encerrar...");
                Console.Write("> Resp: ");
                op = int.Parse(Console.ReadLine());

                switch (op)
                {
                case 1:
                {
                    Console.Clear();
                    Console.WriteLine(myPost.ToString());
                    Console.ReadLine();
                    break;
                }

                case 2:
                {
                    Console.Clear();
                    Console.WriteLine("Entre com os dados da nova postagem: ");
                    Console.Write("Moment (DD/MM/YYYY): ");
                    DateTime dt = DateTime.Parse(Console.ReadLine());
                    Console.Write("Title: ");
                    string title = Console.ReadLine();
                    Console.Write("Content: ");
                    string content = Console.ReadLine();
                    IdPostagem++;
                    Post p = new Post(dt, title, content, IdPostagem);
                    myPost.AddPostInMyPost(p);
                    break;
                }

                case 3:
                {
                    Console.Clear();
                    Console.WriteLine("Informe o ID da postagem para curtir-lo: ");
                    Console.Write("#ID: ");
                    int idLike = int.Parse(Console.ReadLine());
                    myPost.AddLikePost(idLike);
                    break;
                }

                case 4:
                {
                    Console.Clear();
                    Console.WriteLine("Informe o ID da postagem para comenta-lo: ");
                    Console.Write("#ID: ");
                    int idComment = int.Parse(Console.ReadLine());
                    Console.WriteLine("Entre com o texto desejado para comentar a postagem. ");
                    Console.Write("Texto: ");
                    string  textComment = Console.ReadLine();
                    Comment c           = new Comment(textComment);
                    myPost.AddCommentPost(idComment, c);
                    break;
                }

                case 0:
                {
                    Console.Clear();
                    Console.WriteLine("Finalizando aplicação...");
                    Console.WriteLine();
                    break;
                }

                default:
                {
                    Console.WriteLine("Operação inválida!");
                    Console.ReadLine();
                    break;
                }
                }
            }
        }