Exemplo n.º 1
0
 public ActionResult Search(int? page)
 {
     int pageSize = 10;
     int pageNumber = page ?? 1;
     List<IssueModel> issues = new KnowledgeBase.Services.DataBase.Context.Issue(Server.MapPath("~")).getAll();
     SearchModel search = new SearchModel();
     search.issues = issues.ToPagedList(pageNumber, pageSize).ToList();
     search.issuesPaged = issues.ToPagedList(pageNumber, pageSize);
     return View("Search", search);
 }
Exemplo n.º 2
0
 public ActionResult SearchByFilter(SearchModel search)
 {
     if (ModelState.IsValid && !string.IsNullOrEmpty(search.textToSearch))
     {
         List<IssueModel> searchedIssues = new List<IssueModel>();
         var issues = new KnowledgeBase.Services.DataBase.Context.Issue(Server.MapPath("~")).getAll();
         if (search.includeTitle)
         {
             var filtered = issues.Where(i => i.title.Contains(search.textToSearch)).ToList();
             searchedIssues = searchedIssues.Union(filtered).ToList();
         }
         if (search.includeSymptom)
         {
             var filtered = issues.Where(i => i.symptom.Contains(search.textToSearch)).ToList();
             searchedIssues = searchedIssues.Union(filtered).ToList();
         }
         if (search.includeDiagnostic)
         {
             var filtered = issues.Where(i => i.diagnostic.Contains(search.textToSearch)).ToList();
             searchedIssues = searchedIssues.Union(filtered).ToList();
         }
         if (search.includeFix)
         {
             var filtered = issues.Where(i => i.fix.Contains(search.textToSearch)).ToList();
             searchedIssues = searchedIssues.Union(filtered).ToList();
         }
         if (search.includeComments)
         {
             var filtered = issues.Where(i => i.comments.Contains(search.textToSearch)).ToList();
             searchedIssues = searchedIssues.Union(filtered).ToList();
         }
         search.issues = searchedIssues.ToList();
         search.issuesPaged = null;
         return View("Search", search);
     }
     else
     {
         ModelState.Clear();
         return RedirectToAction("Search");
     }
 }