Beispiel #1
0
        public ActionResult Index(string section, string type, string url)
        {
            if (string.IsNullOrEmpty(section))
            {
                //Render all
                return(View("Toc", Documentation.GetAll()));
            }
            var docsSection = Documentation.GetDocs(section);

            if (docsSection == null)
            {
                return(View("SectionNotFound"));
            }
            _breadCrumbsBuilder.Add(docsSection);
            if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(url))
            {
                //Lookup method
                var function = docsSection.Methods.Where(x => x.Path.Equals(url, StringComparison.OrdinalIgnoreCase) && x.HttpMethod.Equals(type, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
                if (function != null)
                {
                    _breadCrumbsBuilder.Add(docsSection, function);
                    return(View("Function", new SectionMethodViewModel(docsSection, function)));
                }
                return(View("FunctionNotFound"));
            }
            return(View("Section", docsSection));
        }
Beispiel #2
0
        public ActionResult Section(string section, string category)
        {
            if (string.IsNullOrEmpty(section))
            {
                return(View("sectionnotfound"));
            }

            var docsSection = Documentation.GetDocs(section);

            if (docsSection == null || !docsSection.Methods.Any())
            {
                return(View("sectionnotfound"));
            }

            const string controller = "portals";

            _breadCrumbsBuilder.Add(docsSection.Name, docsSection, null, controller);

            if (string.IsNullOrEmpty(category))
            {
                var sectionMethods = docsSection.Methods.Where(x => string.IsNullOrEmpty(x.Category)).ToList();
                if (sectionMethods.Any())
                {
                    return(View("section", new SectionViewModel(docsSection, null, sectionMethods)));
                }

                category = docsSection.Methods.OrderBy(x => x.Category).First(x => !string.IsNullOrEmpty(x.Category)).Category;
                return(Redirect(Url.DocUrl(section, category, null, null, "portals")));
            }

            var categoryMethods = docsSection.Methods.Where(x => x.Category.Equals(category, StringComparison.OrdinalIgnoreCase)).ToList();

            if (categoryMethods.Any())
            {
                _breadCrumbsBuilder.Add(category, docsSection.Name, category, null, null, controller);
                return(View("section", new SectionViewModel(docsSection, category, categoryMethods)));
            }

            return(View("sectionnotfound"));
        }