|
|
|
@ -4,22 +4,47 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using ConsoleApp.Menu.Core;
|
|
|
|
|
using Model.Managers;
|
|
|
|
|
|
|
|
|
|
namespace ConsoleApp.Menu
|
|
|
|
|
{
|
|
|
|
|
internal class ConnectionMenu : Entry
|
|
|
|
|
{
|
|
|
|
|
public ConnectionMenu()
|
|
|
|
|
private MasterManager _masterMgr;
|
|
|
|
|
private bool _wrongInput = false;
|
|
|
|
|
|
|
|
|
|
public ConnectionMenu(MasterManager masterManager)
|
|
|
|
|
: base("Connection",
|
|
|
|
|
new Entry.EntryStep("Username: ", typeof(string)),
|
|
|
|
|
new Entry.EntryStep("Password: ", typeof(string)))
|
|
|
|
|
{ }
|
|
|
|
|
new Entry.EntryStep("Mail: ", typeof(string)),
|
|
|
|
|
new Entry.EntryStep("Password: ", typeof(string), true))
|
|
|
|
|
{
|
|
|
|
|
_masterMgr = masterManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Display()
|
|
|
|
|
{
|
|
|
|
|
base.Display();
|
|
|
|
|
|
|
|
|
|
if (_wrongInput)
|
|
|
|
|
{
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
Console.WriteLine("Wrong input...");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IMenu? Return()
|
|
|
|
|
{
|
|
|
|
|
string username = _selectList[0].Item.Input;
|
|
|
|
|
string mail = _selectList[0].Item.Input;
|
|
|
|
|
string password = _selectList[1].Item.Input;
|
|
|
|
|
return new PlainText($"User: {username} connected with password: {password}");
|
|
|
|
|
|
|
|
|
|
if (!_masterMgr.Login(mail, password))
|
|
|
|
|
{
|
|
|
|
|
_wrongInput = true;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|