Пример #1
0
        public async Task <IActionResult> SearchBans(string key)
        {
            var ckey = KeyUtilities.GetCanonicalKey(key);

            if (string.IsNullOrWhiteSpace(ckey) || ckey.Length < 3)
            {
                return(View("badsearch", new BanSearchViewModel()
                {
                    CKey = ckey
                }));
            }

            var searchResults = await _banService.SearchSummariesForKeyAsync(key);

            // If there is only one result, just view it
            if (searchResults.Count() == 1)
            {
                return(RedirectToAction("ViewBans", new { key = searchResults.First().CKey }));
            }

            return(View(new BanSearchViewModel()
            {
                CKey = ckey, Data = searchResults
            }));
        }