public async Task Search() { List <Model.Hairstyle> _hairstylesList = new List <Model.Hairstyle>(); if (HairstyleName == null || HairstyleName == "") { _hairstylesList = await _apiService.GetAll <List <Model.Hairstyle> >(null); } else { HairstyleSearchRequest request = new HairstyleSearchRequest { HairstyleName = HairstyleName }; _hairstylesList = await _apiService.GetAll <List <Model.Hairstyle> >(request); } if (_hairstyles.Count > 0) { _hairstyles.Clear(); } if (_hairstylesList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "No results found for this filter!", "OK"); return; } foreach (var item in _hairstylesList) { _hairstyles.Add(item); } }
private async void BtnSearch_Click(object sender, EventArgs e) { HairstyleSearchRequest searchRequest = new HairstyleSearchRequest { HairstyleName = txtName.Text }; List <Model.Hairstyle> hairstyles = await _apiService.GetAll <List <Model.Hairstyle> >(searchRequest); if (hairstyles.Count == 0) { MessageBox.Show("There are no results for this search", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { dgvHairstyles.AutoGenerateColumns = false; dgvHairstyles.DataSource = hairstyles; } }