Beispiel #1
0
        public string FormAutocompleteResponse(string query)
        {
            var projects    = projectDataAccessObject.Search(query);
            var suggestions = projects.Select(project => project.Name).ToList();
            var queryModel  = new AutocompleteQuery()
            {
                query = query, suggestions = suggestions
            };

            return(JsonConvert.SerializeObject(queryModel));
        }
        public string FormAutocompleteResponseBySurname(string query)
        {
            var employees   = employeeDataAccessObject.DirectSearch(null, query, null, Roles.All, null);
            var suggestions = employees.Select(employee => employee.Surname).ToList();
            var queryModel  = new AutocompleteQuery()
            {
                query = query, suggestions = suggestions
            };

            return(JsonConvert.SerializeObject(queryModel));
        }
Beispiel #3
0
        public List <Movie> MoviesAutocomplete(AutocompleteQuery input, ILambdaContext context)
        {
            if (string.IsNullOrWhiteSpace(input.Phrase))
            {
                return(new List <Movie>());
            }

            var title       = input.Phrase.ToLower().Trim();
            var foundMovies = this.moviesDatabase.Where(x => x.Title.ToLower().Contains(title));

            if (input.Genres?.Any() ?? false)
            {
                foundMovies =
                    foundMovies.Where(movie => input.Genres.Any(genre => movie.Genres.Contains(genre)));
            }

            return(foundMovies.ToList());
        }