diff --git a/MCTG/ConsoleApp/Menu/ConnectionMenu.cs b/MCTG/ConsoleApp/Menu/ConnectionMenu.cs index d4c9949..ef410d2 100644 --- a/MCTG/ConsoleApp/Menu/ConnectionMenu.cs +++ b/MCTG/ConsoleApp/Menu/ConnectionMenu.cs @@ -3,7 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - +using ConsoleApp.Menu.Core; + namespace ConsoleApp.Menu { internal class ConnectionMenu : Entry diff --git a/MCTG/ConsoleApp/Menu/Entry.EntryStep.cs b/MCTG/ConsoleApp/Menu/Core/Entry.EntryStep.cs similarity index 98% rename from MCTG/ConsoleApp/Menu/Entry.EntryStep.cs rename to MCTG/ConsoleApp/Menu/Core/Entry.EntryStep.cs index b58a707..4193cb3 100644 --- a/MCTG/ConsoleApp/Menu/Entry.EntryStep.cs +++ b/MCTG/ConsoleApp/Menu/Core/Entry.EntryStep.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp.Menu +namespace ConsoleApp.Menu.Core { internal abstract partial class Entry { diff --git a/MCTG/ConsoleApp/Menu/Entry.cs b/MCTG/ConsoleApp/Menu/Core/Entry.cs similarity index 98% rename from MCTG/ConsoleApp/Menu/Entry.cs rename to MCTG/ConsoleApp/Menu/Core/Entry.cs index 3a84fff..c1702d3 100644 --- a/MCTG/ConsoleApp/Menu/Entry.cs +++ b/MCTG/ConsoleApp/Menu/Core/Entry.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - -namespace ConsoleApp.Menu +using ConsoleApp.Menu.Core; + +namespace ConsoleApp.Menu.Core { /// /// Define an Entry menu. diff --git a/MCTG/ConsoleApp/Menu/IMenu.cs b/MCTG/ConsoleApp/Menu/Core/IMenu.cs similarity index 95% rename from MCTG/ConsoleApp/Menu/IMenu.cs rename to MCTG/ConsoleApp/Menu/Core/IMenu.cs index 120a387..813d91e 100644 --- a/MCTG/ConsoleApp/Menu/IMenu.cs +++ b/MCTG/ConsoleApp/Menu/Core/IMenu.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp.Menu +namespace ConsoleApp.Menu.Core { /// /// Define a console menu with element selection. diff --git a/MCTG/ConsoleApp/Menu/Menu.cs b/MCTG/ConsoleApp/Menu/Core/Menu.cs similarity index 95% rename from MCTG/ConsoleApp/Menu/Menu.cs rename to MCTG/ConsoleApp/Menu/Core/Menu.cs index 68962db..668b1ae 100644 --- a/MCTG/ConsoleApp/Menu/Menu.cs +++ b/MCTG/ConsoleApp/Menu/Core/Menu.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp.Menu +namespace ConsoleApp.Menu.Core { /// /// Define a selection menu. @@ -44,7 +44,7 @@ namespace ConsoleApp.Menu { _currentLine = value; if (_currentLine <= 0) _currentLine = 0; - else if (_currentLine >= _selectList.Count) _currentLine = _selectList.Count-1; + else if (_currentLine >= _selectList.Count) _currentLine = _selectList.Count - 1; } } @@ -75,7 +75,7 @@ namespace ConsoleApp.Menu /// /// The title of the menu. /// The selections of the menu. - protected Menu(string title, params Selector[] selections ) : this(title) + protected Menu(string title, params Selector[] selections) : this(title) { if (selections == null || selections.Length == 0) { diff --git a/MCTG/ConsoleApp/Menu/PlainText.cs b/MCTG/ConsoleApp/Menu/Core/PlainText.cs similarity index 96% rename from MCTG/ConsoleApp/Menu/PlainText.cs rename to MCTG/ConsoleApp/Menu/Core/PlainText.cs index d5deee1..6439c62 100644 --- a/MCTG/ConsoleApp/Menu/PlainText.cs +++ b/MCTG/ConsoleApp/Menu/Core/PlainText.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - -namespace ConsoleApp.Menu + +namespace ConsoleApp.Menu.Core { /// /// Define a Plain text menu. @@ -36,16 +36,16 @@ namespace ConsoleApp.Menu public StringBuilder InputStr { get; set; } public void DisableWriteMode() - { - // Plain text does not need to do anything for this. + { + // Plain text does not need to do anything for this. } public void EnableWriteMode() - { - // Plain text does not need to do anything for this. + { + // Plain text does not need to do anything for this. } public void SelectNext() - { - // Plain text does not need to do anything for this. + { + // Plain text does not need to do anything for this. } public void SelectPrevious() { diff --git a/MCTG/ConsoleApp/Menu/Selector.cs b/MCTG/ConsoleApp/Menu/Core/Selector.cs similarity index 91% rename from MCTG/ConsoleApp/Menu/Selector.cs rename to MCTG/ConsoleApp/Menu/Core/Selector.cs index f8f71e0..6dce8f0 100644 --- a/MCTG/ConsoleApp/Menu/Selector.cs +++ b/MCTG/ConsoleApp/Menu/Core/Selector.cs @@ -7,7 +7,7 @@ using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp.Menu +namespace ConsoleApp.Menu.Core { /// /// The selector of a menu. @@ -22,7 +22,8 @@ namespace ConsoleApp.Menu /// /// The string that are displayed on the menu. /// - public string Line { + public string Line + { get => _line; private set { @@ -57,7 +58,7 @@ namespace ConsoleApp.Menu { if (other == null) return false; if (other == this) return true; - return other.Line.Equals(this.Line); + return other.Line.Equals(Line); } public override bool Equals(object? obj) diff --git a/MCTG/ConsoleApp/Menu/MainMenu.cs b/MCTG/ConsoleApp/Menu/MainMenu.cs index 8dcbb8b..9bdc7ad 100644 --- a/MCTG/ConsoleApp/Menu/MainMenu.cs +++ b/MCTG/ConsoleApp/Menu/MainMenu.cs @@ -5,7 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - +using ConsoleApp.Menu.Core; + namespace ConsoleApp.Menu { /// diff --git a/MCTG/ConsoleApp/Menu/SearcherRecipe.cs b/MCTG/ConsoleApp/Menu/SearcherRecipe.cs index b7dea49..b3460b8 100644 --- a/MCTG/ConsoleApp/Menu/SearcherRecipe.cs +++ b/MCTG/ConsoleApp/Menu/SearcherRecipe.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; - +using ConsoleApp.Menu.Core; using Model; namespace ConsoleApp.Menu diff --git a/MCTG/ConsoleApp/MenuManager.cs b/MCTG/ConsoleApp/MenuManager.cs index 20cf567..7fb9a70 100644 --- a/MCTG/ConsoleApp/MenuManager.cs +++ b/MCTG/ConsoleApp/MenuManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using ConsoleApp.Menu.Core; namespace ConsoleApp { @@ -23,7 +24,7 @@ namespace ConsoleApp /// /// Each menu called are push in this stack. Then, to return back, we pop this stack to retrive the previous menu. /// - public Stack MenuCallStack { get; set; } + public Stack MenuCallStack { get; set; } #endregion #region Constructors @@ -32,11 +33,11 @@ namespace ConsoleApp /// /// The data manager needed by the menus inside. /// The starting menu, the first that will be push on the call stack. - public MenuManager(DataManager dataManager, Menu.IMenu firstMenu) + public MenuManager(DataManager dataManager, IMenu firstMenu) { DataManager = dataManager; - MenuCallStack = new Stack(); + MenuCallStack = new Stack(); MenuCallStack.Push(firstMenu); } @@ -55,7 +56,7 @@ namespace ConsoleApp public void Loop() { ConsoleKeyInfo cki; - Menu.IMenu menuOnHead; + IMenu menuOnHead; do { menuOnHead = MenuCallStack.Peek(); @@ -72,7 +73,7 @@ namespace ConsoleApp menuOnHead.SelectPrevious(); break; case ConsoleKey.Enter: - Menu.IMenu? retMenu = menuOnHead.Return(); + IMenu? retMenu = menuOnHead.Return(); if (retMenu is null) MenuCallStack.Pop(); else MenuCallStack.Push(retMenu); break; diff --git a/MCTG/Model/Managers/MasterManager.cs b/MCTG/Model/Managers/MasterManager.cs new file mode 100644 index 0000000..a093e71 --- /dev/null +++ b/MCTG/Model/Managers/MasterManager.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Managers +{ + public class MasterManager + { + public static User? CurrentConnectedUser; + public static RecipeCollection? Recipes; + public static List? Users; + + public DataManager DataMgr { get; private set; } + + public MasterManager(IDataManager dataManager) + { + DataMgr = new DataManager(dataManager); + Recipes = DataMgr.GetRecipes("all recipes"); + Users = DataMgr.GetUsers(); + CurrentConnectedUser = null; + } + + public bool LogIn(string mail, string password) + { + if (Users is null) + throw new ArgumentNullException(); + + User user = (User)(from u in Users + where u.Mail == mail + select u); + } + } +} diff --git a/MCTG/Model/User/User.cs b/MCTG/Model/User/User.cs index f335472..22ed1ba 100644 --- a/MCTG/Model/User/User.cs +++ b/MCTG/Model/User/User.cs @@ -131,7 +131,6 @@ namespace Model #endregion - #region Constructors /// @@ -159,7 +158,5 @@ namespace Model #endregion - - } }