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 { /// /// Main menu of the console. Contain the first interaction menus. /// internal class MainMenu : Menu { private MasterManager _masterMgr; public MainMenu(MasterManager masterManager) : base("Main menu") { _masterMgr = masterManager; _allSelectors.Add( new Selector(new SearcherRecipe(_masterMgr), "Recipe search")); _allSelectors.Add( new Selector(new ConnectionMenu(_masterMgr), "Connection")); _allSelectors.Add( new Selector(new ProfileMenu(_masterMgr), "User profile")); _allSelectors.Add( new Selector(new LogoutButton(_masterMgr), "Logout")); _allSelectors.Add( new Selector(new AddRecipeMenu(_masterMgr), "Add recipe")); _allSelectors.Add( new Selector(new AddUserMenu(_masterMgr), "Add user")); _allSelectors.Add( new Selector(new ImportRecipeMenu(_masterMgr), "Import recipe")); _allSelectors.Add( new Selector(new ExportRecipeMenu(_masterMgr), "Export recipe")); } protected override List> SearchInSelection() { List> selectors = base.SearchInSelection(); if (_masterMgr.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(); } } }