示例#1
0
        public ActionResult Configuration()
        {
            ConfigurationViewModel model = new ConfigurationViewModel();

            model.DebugModeList = AppWebUtils.GetSelectListFromEnum(typeof(DebugModes), App.Configuration.DebugMode.ToString());

            return(View(model));
        }
示例#2
0
        public ActionResult Search(FormCollection formVars)
        {
            ListSnippetViewModel model = new ListSnippetViewModel(this);

            model.AppUserState = this.AppUserState;
            model.ErrorDisplay = this.ErrorDisplay;
            model.PageTitle    = "Search Code Snippets";

            model.SearchOrderItems = AppWebUtils.GetSelectListFromEnum(typeof(SearchOrderTypes), "Entered");

            using (busCodeSnippet busSnippet = new busCodeSnippet())
            {
                model.Controller = this;
                model.busSnippet = busSnippet;

                model.Parameters = new CodeSnippetSearchParameters();

                this.TryUpdateModel(model.Parameters);

                var snippetList      = busSnippet.GetSearchList(model.Parameters);
                int snippetListCount = 0;
                if (snippetList != null)
                {
                    snippetListCount = snippetList.Count();
                }

                if (formVars.Count > 0)
                {
                    if (snippetList == null)
                    {
                        this.ErrorDisplay.ShowError("Please provide at least one search criterion.");
                    }
                    else if (snippetListCount < 1)
                    {
                        this.ErrorDisplay.ShowError("No matches found for your search criteria.");
                    }
                }

                if (snippetList != null)
                {
                    model.Paging           = new PagingDetails();
                    model.Paging.PageCount = (int)Math.Ceiling(Convert.ToDecimal(snippetListCount) / Convert.ToDecimal(model.Paging.PageSize));

                    int.TryParse(Request.Params["page"] ?? "1", out model.Paging.Page);

                    if (model.Paging.Page > 0 && snippetListCount > model.Paging.PageSize)
                    {
                        snippetList = snippetList.Skip((model.Paging.Page - 1) * model.Paging.PageSize)
                                      .Take(model.Paging.PageSize);
                    }
                    model.SnippetList = snippetList.ToList();
                }
                else
                {
                    model.SnippetList = new List <CodeSnippetListItem>();
                }


                ActionResult result = this.ApiResult(model.SnippetList);
                if (result != null)
                {
                    return(result);
                }
            }

            return(View("Search", model));
        }