/// <summary> /// Met à jour un blogpostcomment /// </summary> /// <param name="id"></param> /// <param name="content"></param> /// <param name="author"></param> /// <returns></returns> public bool get_blogpostcomment(string id="", string content="", string author="") { BlogPostComment XNewBlogPostComment = new BlogPostComment(id, content, author); blogController controller = new blogController(); controller.UpdateBlogPostComment(XNewBlogPostComment); return true; }
public void UpdateBlogPostComment(BlogPostComment newblogpostcomment) { ElasticClient client = YoupElasticSearch.InitializeConnection(); var response = client.Update<BlogPostComment, BlogPostComment>(u => u .Index("youp") .Id(newblogpostcomment.Id) .Doc(newblogpostcomment) ); }
//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; }
public void TestAddBlogPostComment() { BlogPostComment BlogPostCommentTest = new BlogPostComment("500", "content test", "BlogPostComment Test"); controllerBlog.AddBlogPostComment(BlogPostCommentTest); //test de l'ajout var searchResults = client.Search<BlogPostComment>(s => s.Query(q => q.Term(p => p.Id, "500"))); Assert.AreEqual(1, searchResults.Total); }
public void AddBlogPostComment(BlogPostComment blogpostcomment) { ElasticClient client = YoupElasticSearch.InitializeConnection(); var index = client.Index(blogpostcomment); }
public void TestUpdateBlogPostComment() { BlogPostComment BlogPostCommentTest = new BlogPostComment("700", "content", "BlogPostComment Test"); BlogPostComment newBlogPostComment = new BlogPostComment("700", "content", "BlogPostComment updated"); client.Index(BlogPostCommentTest); controllerBlog.UpdateBlogPostComment(newBlogPostComment); //test de la modification var searchResults = client.Search<BlogPostComment>(s => s.Query(q => q.Term(p => p.Id, "700"))); foreach (BlogPostComment hit in searchResults.Hits) Assert.AreEqual("BlogPostComment updated", hit.Author); }