Пример #1
0
        public ActionResult MySnippets()
        {
            if (string.IsNullOrEmpty(this.AppUserState.UserId))
            {
                List <CodeSnippetListItem> snippetListEmpty = new List <CodeSnippetListItem>();
                this.ViewData["SnippetList"] = snippetListEmpty;
                this.ErrorDisplay.ShowError("You have to log in to see your snippets.");
                return(View());
            }

            using (busCodeSnippet busSnippet = new busCodeSnippet())
            {
                this.ViewData["busSnippet"] = busSnippet;
                var snippetList = busSnippet.GetSnippetsForUser(this.AppUserState.UserId);
                this.ViewData["SnippetList"] = snippetList;
                this.ViewData["PageTitle"]   = "My Snippets";
                ActionResult actionResult = this.ApiResult(snippetList);
                if (actionResult != null)
                {
                    return(actionResult);
                }
            }

            return(View());
        }
Пример #2
0
 /// <summary>
 /// Returns a list of snippets for a given user's id
 /// </summary>
 /// <param name="userId">User id to return snippets for</param>
 /// <param name="count">Number of records to return. 0 returns 10 times default list size.</param>
 /// <returns></returns>
 public List <CodeSnippetListItem> GetSnippetsForUser(string userId, int count)
 {
     using (busCodeSnippet codeSnippet = CodePasteFactory.GetCodeSnippet())
     {
         return(codeSnippet.GetSnippetsForUser(userId, count));
     }
 }
Пример #3
0
        public ActionResult MySnippets()
        {            
            if (string.IsNullOrEmpty(this.AppUserState.UserId))
            {
                List<CodeSnippetListItem> snippetListEmpty = new List<CodeSnippetListItem>();
                this.ViewData["SnippetList"] = snippetListEmpty;
                this.ErrorDisplay.ShowError("You have to log in to see your snippets.");
                return View();
            }

            using (busCodeSnippet busSnippet = new busCodeSnippet())
            {
                this.ViewData["busSnippet"] = busSnippet;
                var snippetList = busSnippet.GetSnippetsForUser(this.AppUserState.UserId);
                this.ViewData["SnippetList"] = snippetList;
                this.ViewData["PageTitle"] = "My Snippets";
                ActionResult actionResult = this.ApiResult(snippetList);
                if (actionResult != null)
                    return actionResult;
            }

            return View();
        }