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.
56 lines
1.7 KiB
56 lines
1.7 KiB
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<PreparationStep> steps = new List<PreparationStep>();
|
|
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;
|
|
}
|
|
}
|
|
}
|