public async Task <IEnumerable <RecipeApiModel> > Search(SearchRecipeParameters parameters) { var all = await recipeAdapter.GetAllRecipes(); BaseFilter <RecipeApiModel> filter = new NameFilter <RecipeApiModel>(parameters.Name); if (parameters.Type != ERecipeType.None) { filter = new RecipeTypeFilter(parameters.Type, filter); } return(filter.Filter(all)); }
public async Task <List <RecipeModel> > Search(SearchRecipeParameters parameters) { try { var json = JsonConvert.SerializeObject(parameters); var data = new StringContent(json, Encoding.UTF8, "application/json"); var client = new HttpClient(); var response = await client.PostAsync(new Uri("http://localhost:5005/api/recipe/search"), data); string result = response.Content.ReadAsStringAsync().Result; var jsonReslt = JsonConvert.DeserializeObject <List <RecipeModel> >(result); client.Dispose(); return(jsonReslt); } catch (Exception) { return(new List <RecipeModel>()); } }
public async Task <IActionResult> Search([FromBody] SearchRecipeParameters parameters) { var result = await recipeService.Search(parameters); return(Ok(result)); }