public IReadOnlyCollection <EntryViewModel> Search(string searchText)
        {
            var foundEntries = phoneBookService.Search(searchText);

            //Normally would use automapper for mapping but since its such a small use case decided to map manually
            return(foundEntries.Select(entry => new EntryViewModel(entry.Name, entry.PhoneNumber)).ToList()
                   .AsReadOnly());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SearchPhoneBook([FromQuery] SearchPhoneBookRequest searchPhoneBookRequest)
        {
            var response = await _phoneBookService.Search(searchPhoneBookRequest, GetUserToken().UserId);

            return(Ok(response));
        }