You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using Model;
|
|
|
|
namespace ConsoleApp.Menu
|
|
{
|
|
/// <summary>
|
|
/// An utility to find a recipe.
|
|
/// </summary>
|
|
internal class SearcherRecipe : Menu<Recipe>
|
|
{
|
|
private readonly RecipeCollection _recipeCollectionOnSearch;
|
|
|
|
public SearcherRecipe(RecipeCollection recipeCollection) : base("Search recipe")
|
|
{
|
|
_recipeCollectionOnSearch = recipeCollection;
|
|
_allSelectors = ConvertRecipeCollectionInSelectors();
|
|
_selectList = _allSelectors;
|
|
}
|
|
|
|
#region Methods
|
|
private List<Selector<Recipe>> ConvertRecipeCollectionInSelectors()
|
|
{
|
|
List<Selector<Recipe>> newSelectors = new List<Selector<Recipe>>();
|
|
foreach (Recipe recipe in _recipeCollectionOnSearch)
|
|
{
|
|
newSelectors.Add(new Selector<Recipe>(recipe, $"[{recipe.Id}]: {recipe.Title}"));
|
|
}
|
|
return newSelectors;
|
|
}
|
|
|
|
public override IMenu? Return()
|
|
{
|
|
if (CurrentSelected == null)
|
|
throw new ArgumentNullException("CurrentSelected");
|
|
|
|
return new PlainText(CurrentSelected.ToString());
|
|
}
|
|
#endregion
|
|
}
|
|
}
|