using ConsoleApp.Menu.Core; using Model; using Model.Managers; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp.Menu { internal class AddRecipeMenu : Entry { MasterManager masterMgr; public AddRecipeMenu(MasterManager masterManager) : base("Add recipe", new Entry.EntryStep("Title: ", typeof(string)), new Entry.EntryStep("new step: ", typeof(string)), new Entry.EntryStep("new step: ", typeof(string)), new Entry.EntryStep("new step: ", typeof(string)), new Entry.EntryStep("new step: ", typeof(string))) { masterMgr = masterManager; } public override IMenu? Return() { string title = _selectList[0].Item.Input; int order = 1; List steps = new List(); for (int i = 1; i <= 4; i++) { if (string.IsNullOrEmpty(_selectList[i].Item.Input)) continue; steps.Add(new PreparationStep(order++, _selectList[i].Item.Input)); } Recipe recipe = new Recipe( title: title, type: RecipeType.Unspecified, priority: Priority.Fast, id: null, authorMail: masterMgr.CurrentConnectedUser?.Mail, picture: null) { PreparationSteps = steps }; masterMgr.AddRecipe(recipe); return null; } } }