/// <summary>
 /// Met à jour un blog
 /// </summary>
 /// <param name="id"></param>
 /// <param name="content"></param>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool get_blog(string id="", string content="", string category="")
 {
     Blog XNewBlog = new Blog(id, content, category);
     blogController controller = new blogController();
     controller.UpdateBlog(XNewBlog);
     return true;
 }
Beispiel #2
0
        public void TestAddBlog()
        {
            Blog BlogTest = new Blog("500", "Content test", "Blog Test");

            controllerBlog.AddBlog(BlogTest); //test de l'ajout

            var searchResults = client.Search<Blog>(s => s.Query(q => q.Term(p => p.Id, "500")));
            Assert.AreEqual(1, searchResults.Total);
        }
Beispiel #3
0
 public void UpdateBlog(Blog newblog)
 {
     ElasticClient client = YoupElasticSearch.InitializeConnection();
     var response = client.Update<Blog, Blog>(u => u
         .Index("youp")
         .Id(newblog.Id)
         .Doc(newblog)
      );
 }
Beispiel #4
0
        //Migration blog
        public static bool blogMigration(ElasticClient elastic)
        {
            using (var context = new YoupDEVEntities())
            {
                var blogs = (from b in context.BLOG_Blog
                             select b).ToList<BLOG_Blog>();
                foreach (var blog in blogs)
                {
                    Blog blogElastic = new Blog(blog.Blog_id.ToString(), blog.TitreBlog, blog.Theme_id.ToString());
                    var indexB = elastic.Index(blogElastic);
                    /* var visits = (from v in context.BLOG_Visite
                                  where v.Blog_Id == blog.Blog_id
                                  select v).Count();*/

                    var articles = (from a in context.BLOG_Article
                                    where a.Blog_id == blog.Blog_id
                                    select a).ToList<BLOG_Article>();

                    foreach (var article in articles)
                    {
                        BlogPost articleElastic = new BlogPost(article.Article_id.ToString(), article.ContenuArticle, blog.Utilisateur_id.ToString(), article.TitreArticle);
                        var indexA = elastic.Index(articleElastic);

                        var comments = (from c in context.BLOG_Commentaire
                                        where c.Article_id == article.Article_id
                                        select c).ToList<BLOG_Commentaire>();
                        foreach (var comment in comments)
                        {
                            BlogPostComment commentElastic = new BlogPostComment(comment.Commentaire_id.ToString(), comment.ContenuCommentaire, comment.Utilisateur_id.ToString());
                            var indexBPC = elastic.Index(commentElastic);
                        }
                    }
                }
            }
            return true;
        }
Beispiel #5
0
 public void AddBlog(Blog blog)
 {
     ElasticClient client = YoupElasticSearch.InitializeConnection();
     var index = client.Index(blog);
 }
Beispiel #6
0
        public void TestUpdateBlog()
        {
            Blog BlogTest = new Blog("700", "Content", "Blog Test");
            Blog newBlog = new Blog("700", "Content", "Blog Updated");
            client.Index(BlogTest);

            controllerBlog.UpdateBlog(newBlog); //test de la modification

            var searchResults = client.Search<Blog>(s => s.Query(q => q.Term(p => p.Id, "700")));
            foreach (Blog hit in searchResults.Hits)
                Assert.AreEqual("Blog updated", hit.Categorie);
        }