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.
SAE-2.01/MCTG/ConsoleApp/Menu/MainMenu.cs

55 lines
2.1 KiB

using Model;
using DataPersistence;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp.Menu.Core;
using Model.Managers;
namespace ConsoleApp.Menu
{
/// <summary>
/// Main menu of the console. Contain the first interaction menus.
/// </summary>
internal class MainMenu : Menu<IMenu>
{
public MainMenu(MasterManager masterManager)
: base("Main menu")
{
_allSelectors.Add(
new Selector<IMenu>(new SearcherRecipe(masterManager), "Recipe search"));
_allSelectors.Add(
new Selector<IMenu>(new ConnectionMenu(masterManager), "Connection"));
_allSelectors.Add(
new Selector<IMenu>(new ProfileMenu(masterManager), "User profile"));
_allSelectors.Add(
new Selector<IMenu>(new LogoutButton(masterManager), "Logout"));
_allSelectors.Add(
new Selector<IMenu>(new AddRecipeMenu(masterManager), "Add recipe"));
_allSelectors.Add(
new Selector<IMenu>(new AddUserMenu(masterManager), "Add user"));
_allSelectors.Add(
new Selector<IMenu>(new ImportRecipeMenu(masterManager), "Import recipe"));
_allSelectors.Add(
new Selector<IMenu>(new ExportRecipeMenu(masterManager), "Export recipe"));
}
protected override List<Selector<IMenu>> SearchInSelection()
{
List<Selector<IMenu>> selectors = base.SearchInSelection();
if (MasterManager.CurrentConnectedUser == null)
return selectors.Except(selectors.Where(s => s.Line == "User profile"))
.Except(selectors.Where(s => s.Line == "Logout"))
.Except(selectors.Where(s => s.Line == "Add recipe")).ToList();
else
return selectors.Except(selectors.Where(s => s.Line == "Connection")).ToList();
}
}
}