Example #1
0
        public static void Run(HospitalContext db, IUIManager uiManager)
        {
            string options = "Options:" + Environment.NewLine +
                             "Sign In: email password name speciality" + Environment.NewLine +
                             "Log In: email password" + Environment.NewLine +
                             "Exit";
            Doctor doctor = null;

            while (true)
            {
                uiManager.WriteLine(options);
                string[] commandParts = uiManager.ReadLine().Split(' ');

                switch (commandParts[0])
                {
                case "Sign":
                    string email      = commandParts[2];
                    string password   = commandParts[3];
                    string name       = commandParts[4];
                    string speciality = commandParts[5];

                    doctor = Populator.AddDoctor(db, name, speciality, email, password);

                    if (doctor == null)
                    {
                        uiManager.WriteLine("Failed to sign!!");
                    }
                    else
                    {
                        uiManager.WriteLine("Successfully signed!!");
                    }
                    break;

                case "Log":
                    email    = commandParts[2];
                    password = commandParts[3];

                    doctor = Authorization.LogIn(db, email, password);
                    if (doctor == null)
                    {
                        uiManager.WriteLine("Failed to loggin!!");
                    }
                    else
                    {
                        uiManager.WriteLine("Successfully logged!!");
                    }
                    break;

                case "Exit": return;
                }

                uiManager.ReadLine();
                uiManager.Clean();
            }
        }