Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public ActionResult Method(string section, string type, string url)
        {
            if (string.IsNullOrEmpty(section))
            {
                return(View("sectionnotfound"));
            }

            var docsSection = Documentation.GetDocs(section);

            if (docsSection == null)
            {
                return(View("sectionnotfound"));
            }

            const string controller = "portals";

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

            if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(url))
            {
                var method = docsSection.Methods.SingleOrDefault(x => x.Path.Equals(url, StringComparison.OrdinalIgnoreCase) && x.HttpMethod.Equals(type, StringComparison.OrdinalIgnoreCase));
                if (method != null)
                {
                    if (!string.IsNullOrEmpty(method.Category))
                    {
                        _breadCrumbsBuilder.Add(method.Category, docsSection.Name, method.Category, null, null, controller);
                    }

                    var text = !string.IsNullOrEmpty(method.ShortName)
                                   ? method.ShortName
                                   : (!string.IsNullOrEmpty(method.Summary)
                                          ? method.Summary
                                          : method.FunctionName);

                    _breadCrumbsBuilder.Add(text, docsSection, method, controller);

                    return(View("method", new MethodViewModel(docsSection, method)));
                }
            }

            return(View("methodnotfound"));
        }
Ejemplo n.º 3
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"));
        }