Exemple #1
0
        public ActionResult Search(string q)
        {
            HelpPermissions.ViewHelp.AssertAuthorized();

            Stopwatch sp = new Stopwatch();

            sp.Start();
            Regex regex = new Regex(Regex.Escape(q.RemoveDiacritics()), RegexOptions.IgnoreCase);
            List <List <SearchResult> > results = new List <List <SearchResult> >();

            results.AddRange(from eh in HelpLogic.GetEntityHelps()
                             select eh.Search(regex).ToList() into l
                             where l.Any()
                             select l);

            //We add the appendices
            results.AddRange(from a in HelpLogic.GetAppendixHelps()
                             let result = a.Search(regex)
                                          where result != null
                                          select new List <SearchResult> {
                result
            });

            //We add the namespaces
            results.AddRange(from a in HelpLogic.GetNamespaceHelps()
                             let result = a.Search(regex)
                                          where result != null
                                          select new List <SearchResult> {
                result
            });

            results = results.OrderBy(a => a.First().IsDescription).ThenBy(a => a.First().MatchType).ThenBy(a => a.First().TypeSearchResult).ToList();

            sp.Stop();
            ViewData["time"]             = sp.ElapsedMilliseconds;
            ViewData[ViewDataKeys.Title] = q + " - " + HelpMessage.Buscador.NiceToString();
            return(View(HelpClient.SearchResults, results));
        }