Exemple #1
0
        /// <summary>
        /// /list/recent
        /// /list/tag/C#
        /// </summary>
        /// <param name="listAction"></param>
        /// <param name="listFilter"></param>
        /// <returns></returns>
        public ActionResult List(string listAction, string listFilter)
        {
            if (listAction == "MySnippets")
            {
                return(MySnippets());
            }
            else if (listAction == "MyFavorites")
            {
                return(MyFavorites());
            }

            using (busCodeSnippet busSnippet = new busCodeSnippet())
            {
                var snippetList = busSnippet.GetSnippetList(listAction, listFilter);
                busSnippet.Dispose();


                //if (listAction == "recent")
                //{
                //    // keep the snippetlist short
                //    if (snippetList != null)
                //        snippetList = snippetList.Take(20).ToList();
                //}
                this.ViewData["busSnippet"]  = busSnippet;
                this.ViewData["SnippetList"] = snippetList;

                if (listAction == "tag")
                {
                    this.ViewData["PageTitle"] = "Recent snippets matching tags of " + listFilter;
                    if (snippetList.Count < 1)
                    {
                        Response.StatusCode = 404;
                        ErrorController.ShowErrorPage("Invalid tag", "You've entered a tag that is not valid or has no related entries.");
                    }
                }
                else if (listAction == "language")
                {
                    this.ViewData["PageTitle"] = "Recent snippets matching language of " + listFilter;
                }
                else if (listAction == "user")
                {
                    if (snippetList.Count > 0)
                    {
                        this.ViewData["PageTitle"] = "Recent snippets for: " + snippetList.First().Author;
                    }
                    else
                    {
                        this.ViewData["PageTitle"] = "Recent snippets for user: "******"List"));
            }
        }
Exemple #2
0
 public List <CodeSnippetListItem> ListSnippets(string filter, string filterParameter)
 {
     using (busCodeSnippet codeSnippet = CodePasteFactory.GetCodeSnippet())
     {
         List <CodeSnippetListItem> snippets = codeSnippet.GetSnippetList(filter, filterParameter);
         return(snippets);
     }
 }
Exemple #3
0
 /// <summary>
 /// Returns a list of recent snippets
 /// </summary>
 /// <returns></returns>
 public List <CodeSnippetListItem> GetRecentSnippets()
 {
     using (busCodeSnippet codeSnippet = CodePasteFactory.GetCodeSnippet())
     {
         List <CodeSnippetListItem> items = codeSnippet.GetSnippetList("recent", null);
         return(items);
     }
 }
Exemple #4
0
 public ActionResult Feed()
 {
     using (busCodeSnippet busSnippet = new busCodeSnippet())
     {
         this.ViewData["busSnippet"] = busSnippet;
         var snippetList = busSnippet.GetSnippetList("recent", App.Configuration.MaxListDisplayCount.ToString());
         string format = Request.QueryString["Format"];
         if (string.IsNullOrEmpty(format))
             this.Format = "rss";
         ActionResult actionResult = this.ApiResult(snippetList);
         return actionResult;
     }
 }
Exemple #5
0
 public ActionResult Feed()
 {
     using (busCodeSnippet busSnippet = new busCodeSnippet())
     {
         this.ViewData["busSnippet"] = busSnippet;
         var    snippetList = busSnippet.GetSnippetList("recent", App.Configuration.MaxListDisplayCount.ToString());
         string format      = Request.QueryString["Format"];
         if (string.IsNullOrEmpty(format))
         {
             this.Format = "rss";
         }
         ActionResult actionResult = this.ApiResult(snippetList);
         return(actionResult);
     }
 }
        /// <summary>
        /// /list/recent
        /// /list/tag/C#        
        /// </summary>
        /// <param name="listAction"></param>
        /// <param name="listFilter"></param>
        /// <returns></returns>        
        public ActionResult List(string listAction, string listFilter)
        {
            if (listAction == "MySnippets")
                return MySnippets();
            else if (listAction == "MyFavorites")
                return MyFavorites();

            using (busCodeSnippet busSnippet = new busCodeSnippet())
            {
                var snippetList = busSnippet.GetSnippetList(listAction, listFilter);
                busSnippet.Dispose();

                this.ViewData["busSnippet"] = busSnippet;
                this.ViewData["SnippetList"] = snippetList;

                if (listAction == "tag")
                {
                    this.ViewData["PageTitle"] = "Recent snippets matching tags of " + listFilter;
                    if (snippetList.Count < 1)
                    {
                        Response.StatusCode = 404;
                        ErrorController.ShowErrorPage("Invalid tag", "You've entered a tag that is not valid or has no related entries.");
                    }
                }
                else if (listAction == "language")
                    this.ViewData["PageTitle"] = "Recent snippets matching language of " + listFilter;
                else if (listAction == "user")
                {
                    if (snippetList.Count > 0)
                        this.ViewData["PageTitle"] = "Recent snippets for: " + snippetList.First().Author;
                    else
                        this.ViewData["PageTitle"] = "Recent snippets for user: "******"List");
            }
        }