当前位置: 首页>>代码示例>>C#>>正文


C# IArticleService.DeleteArticle方法代码示例

本文整理汇总了C#中IArticleService.DeleteArticle方法的典型用法代码示例。如果您正苦于以下问题:C# IArticleService.DeleteArticle方法的具体用法?C# IArticleService.DeleteArticle怎么用?C# IArticleService.DeleteArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IArticleService的用法示例。


在下文中一共展示了IArticleService.DeleteArticle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ArticleModule

 public ArticleModule(IArticleService service)
     : base("/article")
 {
     Get ["/tag"] = _ => {
         return "Tags";
     };
     Get ["/{slug}"] = _ => {
         string slug = _.slug;
         var article = service.Table.FirstOrDefault (ssss => ssss.Slug == slug);
         if (article != null) {
             string article_html = TemplatesCache.Current.Items["article_template"].Replace ("{article.content}", article.Content);
             article_html = article_html.Replace ("{article.title}", article.Title);
             article_html=article_html.Replace ("{article.href}","/article/"+article.Slug);
             article_html=TemplatesCache.Current.Items["index_template"].Replace ("{content}",article_html);
             article_html=article_html.Replace ("{strapdown}",TemplatesCache.Current.Items["strapdown_js"]);
             article_html=article_html.Replace ("{site.name}",TemplatesCache.Current.Items["site_name"]);
             article_html=article_html.Replace ("{copyright}",TemplatesCache.Current.Items["copy_right"]);
             return article_html;
         } else {
             return "Article Not Found !";
         }
     };
     Get ["/tag/{tag}"] = _ => {
         string tag = _.tag;
         return Response.AsJson (service.List (a => a.Tag.IndexOf (tag) > -1));
     };
     Get ["/"] = _ => {
         return Response.AsJson (service.Table.ToList ());
     };
     Post ["/"] = _ => {
         var article = this.Bind<Article> ();
         article.CreateTime=DateTime.Now;
         article.ID=DateTime.Now.ToString ("yyyyMMdd")+service.Table.Count ();
         service.AddArticle (article);
         return Response.AsJson (Message.Success);
     };
     Post ["/update"] = _ => {
         var article = this.Bind <Article>();
         service.UpdateArticle (article);
         return Response.AsJson (Message.Success);
     };
     Put ["/"] = _ => {
         var data = this.Bind <Article> ();
         service.UpdateArticle (data);
         return Response.AsJson (Message.Success);
     };
     Delete ["/id/{id}"] = _ => {
         string id=_.id;
         var article=service.GetSingleByID (id);
         service.DeleteArticle (article);
         return Response.AsJson (Message.Success);
     };
     Get ["/editor/{id}"] = _ => {
         string id=_.id;
         var article = service.GetSingleByID (id);
         string editor_template = TemplatesCache.Current.Items["editor_template"];
         editor_template=editor_template.Replace ("{post_url}","/article/update");
         editor_template=editor_template.Replace ("{title}",article.Title);
         editor_template=editor_template.Replace ("{slug}",article.Slug);
         editor_template=editor_template.Replace ("{tags}",article.Tag);
         editor_template=editor_template.Replace ("{content}",article.Content);
         return editor_template;
     };
     Get ["/editor"] = _ => {
         string editor_template = TemplatesCache.Current.Items["editor_template"];
         editor_template=editor_template.Replace ("{post_url}","/article/");
         editor_template=editor_template.Replace ("{title}","");
         editor_template=editor_template.Replace ("{slug}","");
         editor_template=editor_template.Replace ("{tags}","");
         editor_template=editor_template.Replace ("{content}","");
         return editor_template;
     };
 }
开发者ID:Jeremaihloo,项目名称:FreeRoo,代码行数:73,代码来源:ArticleModule.cs


注:本文中的IArticleService.DeleteArticle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。