Ejemplo n.º 1
0
        public JsonResult Search(string searchString)
        {
            var characters = _characterService
                             .Search(searchString);

            if (!characters.Any())
            {
                return(ErrorResponse("Not Found"));
            }

            return(MultipleResults(CharacterViewModelHelpers.ConvertToViewModels(characters.ToList())));
        }
        public JsonResult Search(string searchString)
        {
            if (string.IsNullOrWhiteSpace(searchString))
            {
                return(ErrorResponse("Search string cannot be empty"));
            }

            var characters = _characterService.Search(searchString);

            if (!characters.Any())
            {
                return(ErrorResponse("Cannot find any characters with the provided search string"));
            }

            return(MultipleResults(CharacterViewModelHelpers.ConvertToViewModels(characters.ToList())));
        }