예제 #1
0
        public IActionResult Search(string term)
        {
            var model = new SearchResultModel(Renderer);

            term       = term.ToLower();
            model.Term = term;

            using (var db = new FusekiContext())
            {
                var art = db.Articles
                          .Include(el => el.Tags)
                          .Where(el => el.Title.ToLower().Contains(term))
                          .OrderBy(el => el.Title);
                model.TitleMatches = art.ToList();

                var body = db.Articles
                           .Include(el => el.Tags)
                           .Where(el => el.Body.ToLower().Contains(term))
                           .OrderBy(el => el.Title);
                model.BodyMatches = body.ToList();

                //var tags = db.Tags.Where(el => el.Name.ToLower().Contains(term));
                //model.TagMatches = tags.ToList();
            }
            ViewData["Title"] = $"Search for: {term}";
            return(View("SearchResult", model));
        }
예제 #2
0
        public IActionResult Search(string term)
        {
            Logger.LogMessage($"Searched for: {term}");
            var model = new SearchResultModel(Renderer);

            term       = term.ToLower();
            model.Term = term;

            using (var db = new FusekiContext())
            {
                var art = db.Articles.Where(el => el.Title.ToLower().Contains(term));
                model.TitleMatches = art.ToList();

                var body = db.Articles.Where(el => el.Body.ToLower().Contains(term));
                model.BodyMatches = body.ToList();

                //var tags = db.Tags.Where(el => el.Name.ToLower().Contains(term));
                //model.TagMatches = tags.ToList();
            }

            return(new JsonResult(model));
        }