diff options
| author | Michael <[email protected]> | 2017-04-07 10:47:11 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-07 10:47:11 -0400 |
| commit | 5eea4787f1bdc384451c18d5a693e65a4ed38601 (patch) | |
| tree | 2f4eead1093da297807494c1d489831b8e0e5122 /Project-Unite/Controllers/HomeController.cs | |
| parent | 5860170c1fed2342232d7e35015b669e8b8ec471 (diff) | |
| download | project-unite-5eea4787f1bdc384451c18d5a693e65a4ed38601.tar.gz project-unite-5eea4787f1bdc384451c18d5a693e65a4ed38601.tar.bz2 project-unite-5eea4787f1bdc384451c18d5a693e65a4ed38601.zip | |
add search system (downloads and topics)
Diffstat (limited to 'Project-Unite/Controllers/HomeController.cs')
| -rw-r--r-- | Project-Unite/Controllers/HomeController.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/HomeController.cs b/Project-Unite/Controllers/HomeController.cs index 1c648e9..85570a8 100644 --- a/Project-Unite/Controllers/HomeController.cs +++ b/Project-Unite/Controllers/HomeController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; +using Project_Unite.Models; namespace Project_Unite.Controllers { @@ -33,5 +34,24 @@ namespace Project_Unite.Controllers { return View(); } + + [HttpPost] + public ActionResult Search(string query) + { + var result = new SearchResult(); + query = query.ToLower(); + using(var db = new ApplicationDbContext()) + { + result.Downloads = db.Downloads.Where(x => x.Name.ToLower().Contains(query) || x.Changelog.ToLower().Contains(query)); + result.ForumPosts = db.ForumPosts.Where(x => x.Body.ToLower().Contains(query)); + result.ForumTopics = db.ForumTopics.Where(x => x.Subject.ToLower().Contains(query)); + result.Skins = db.Skins.Where(x => x.Name.ToLower().Contains(query) || x.ShortDescription.ToLower().Contains(query) || x.FullDescription.ToLower().Contains(query)); + result.Users = db.Users.Where(x => x.DisplayName.ToLower().Contains(query)||x.Bio.ToLower().Contains(query)||x.Interests.ToLower().Contains(query)||x.Hobbies.ToLower().Contains(query)); + result.WikiPages = db.WikiPages.Where(x => x.Name.ToLower().Contains(query) || x.Contents.ToLower().Contains(query)); + } + + //Holy crap that search was... long. + return View(result); + } } }
\ No newline at end of file |
