public T LogIn(string username, string password)
        {
            T user = _db.GetAll().SingleOrDefault(x => x.Username == username && x.Password == password);

            if (user == null)
            {
                //("[Error] Username or password did not match..", Color)
                Console.ReadLine();
                return(null);
            }

            return(user);
        }
Exemplo n.º 2
0
        public T LogIn(string username, string password)
        {
            T user = _db.GetAll()
                     .SingleOrDefault(x => x.Username == username && x.Password == password);

            if (user == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[Error] Username or password did not match...");
                Console.ResetColor();
                //("[Error] Username or password did not match..", Color)
                //Console.ReadLine();
                return(null);
            }

            return(user);
        }
 public List <T> GetTrainings()
 {
     return(_db.GetAll());
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = false
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = false
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = true
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = false
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = false
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = true
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = false
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = true
            });
            studentDb.insert(new Students()
            {
                Username = "******", Password = "******", IsItFinished = true
            });

            GetPoints getPoin = new GetPoints(Validation.ReturnPoints);

            Questions questions = new Questions();

            RegisServices <Students> registerStudent = new RegisServices <Students>();
            RegisServices <Teachers> registerTeacher = new RegisServices <Teachers>();


            Console.WriteLine("ENTER: 1 - student | 2 - teacher");
            int num;

            bool isItSTudentOrTeacher = int.TryParse(Console.ReadLine(), out num);

            if (isItSTudentOrTeacher && num == 1)
            {
                Students studentOne = new Students();
logs:
                Console.WriteLine("Register: Press 1, Log in Press 2");
                int  logNum;
                bool isItRegister = int.TryParse(Console.ReadLine(), out logNum);
                if (isItRegister && logNum == 1)
                {
                    string username;
                    string password;
                    bool   IsLessThen = true;
                    while (IsLessThen)
                    {
                        Console.WriteLine("- REGISTER -");
                        Console.WriteLine("=========================");
                        Console.WriteLine("Enter UserName");
                        username = Console.ReadLine().Trim();
                        Console.WriteLine("Enter Password");
                        password = Console.ReadLine().Trim();

                        IsLessThen = Validation.IsStringLessThen(username, password);
                        if (IsLessThen == false)
                        {
                            registerStudent.Register(username, password, studentOne);
                            studentDb.insert(studentOne);
                            goto logs;
                        }
                    }
                }
                else if (isItRegister && logNum == 2)
                {
                    Console.WriteLine("- LOG IN -");
                    Console.WriteLine("=========================");
                    string username;
                    string password;
                    Console.WriteLine("Enter UserName");
                    username = Console.ReadLine().Trim();
                    Console.WriteLine("Enter Password");
                    password = Console.ReadLine().Trim();
                    registerStudent.LogIn(username, password, studentOne);
                    var student10 = studentDb.GetById(10);
                    Console.ResetColor();
                    Console.WriteLine("   PRESS ENTER: \n - START TEST -");
                    Console.WriteLine("=========================");
                    Console.ReadLine();

                    Console.WriteLine(" QUESTION 1");
                    Console.WriteLine("____________________");
                    ExamQuestions.ShowQuestions(0, 1);

                    Console.WriteLine("-------------------------");
                    Console.Write(" Answare: ");
                    getPoin(1, int.Parse(Console.ReadLine()), 2);
                    Console.WriteLine("-------------------------");
                    Console.ReadLine();

                    Console.WriteLine(" QUESTION 2");
                    Console.WriteLine("____________________");
                    ExamQuestions.ShowQuestions(1, 2);

                    Console.WriteLine("-------------------------");
                    Console.Write(" Answare: ");
                    getPoin(2, int.Parse(Console.ReadLine()), 7);
                    Console.WriteLine("-------------------------");
                    Console.ReadLine();

                    Console.WriteLine(" QUESTION 3");
                    Console.WriteLine("____________________");
                    ExamQuestions.ShowQuestions(2, 3);

                    Console.WriteLine("-------------------------");
                    Console.Write(" Answare: ");
                    getPoin(3, int.Parse(Console.ReadLine()), 4);
                    Console.WriteLine("-------------------------");
                    Console.ReadLine();

                    Console.WriteLine(" QUESTION 4");
                    Console.WriteLine("____________________");
                    ExamQuestions.ShowQuestions(3, 4);

                    Console.WriteLine("-------------------------");
                    Console.Write(" Answare: ");
                    getPoin(4, int.Parse(Console.ReadLine()), 5);
                    Console.WriteLine("-------------------------");
                    Console.ReadLine();

                    Console.WriteLine(" QUESTION 5");
                    Console.WriteLine("____________________");
                    ExamQuestions.ShowQuestions(4, 5);

                    Console.WriteLine("-------------------------");
                    Console.Write(" Answare: ");
                    getPoin(5, int.Parse(Console.ReadLine()), 3);
                    Console.WriteLine("-------------------------");
                    Console.ReadLine();

                    Console.WriteLine("TEST END");
                    Console.WriteLine("Thank you about your time and finished the test");
                    Messages.ShowMessages($"Points = {Validation.Points}", ConsoleColor.Yellow);

                    Messages.ShowMessages(student10.ShowInfo(), ConsoleColor.DarkCyan);
                    Console.ResetColor();
                    Console.WriteLine("++++++++++++++++++++++++++++++++");
                    Console.WriteLine("TRUE ANSWARES");
                    Validation.FirstAnsware(questions);
                    Console.WriteLine("-------------------------");
                    Console.BackgroundColor = ConsoleColor.White;
                    Messages.ShowMessages("LOG OUT", ConsoleColor.DarkMagenta);
                    Console.ResetColor();
                }
                else
                {
                    Messages.ShowMessages("ERROR - Incorect input", ConsoleColor.Red);
                }
            }
            else if (isItSTudentOrTeacher && num == 2)
            {
                Teachers teacherOne = new Teachers();
logs:

                Console.WriteLine("Register: Press 1, Log in Press 2");
                int  logNum;
                bool isItRegister = int.TryParse(Console.ReadLine(), out logNum);
                if (isItRegister && logNum == 1)
                {
                    string username;
                    string password;
                    bool   IsLessThen = true;
                    while (IsLessThen)
                    {
                        Console.WriteLine("- REGISTER -");
                        Console.WriteLine("=========================");
                        Console.WriteLine("Enter UserName");
                        username = Console.ReadLine().Trim();
                        Console.WriteLine("Enter Password");
                        password = Console.ReadLine().Trim();

                        IsLessThen = Validation.IsStringLessThen(username, password);
                        if (IsLessThen == false)
                        {
                            registerTeacher.Register(username, password, teacherOne);
                            teachersDb.insert(teacherOne);
                            goto logs;
                        }
                    }
                }
                else if (isItRegister && logNum == 2)
                {
                    Console.WriteLine("- LOG IN -");
                    Console.WriteLine("=========================");
                    string username;
                    string password;
                    Console.WriteLine("Enter UserName");
                    username = Console.ReadLine().Trim();
                    Console.WriteLine("Enter Password");
                    password = Console.ReadLine().Trim();
                    registerTeacher.LogIn(username, password, teacherOne);
                    var teacher1 = teachersDb.GetById(1);
                    teacherOne.students.AddRange(studentDb.GetAll());
                    Console.WriteLine(teacher1.ShowInfo());
                    Console.ResetColor();
                    Console.WriteLine("============================");
                    Console.WriteLine("Your students");
                    teacher1.ShowStudents();
                    Console.WriteLine("Do you want see wich and how many finished queez? Y/N");
                    char yesNo = char.Parse(Console.ReadLine().ToUpper().Trim());

                    if (yesNo == 'Y')
                    {
                        var std = studentDb.GetAll();
                        Validation.PrintStudentDidQuezzOrNot <Students>(std);
                    }
                    else if (yesNo == 'N')
                    {
                        Messages.ShowMessages("Have a nice day professor. \n  \r \r  LOG OUT", ConsoleColor.Yellow);
                        Console.ReadLine();
                    }
                    else
                    {
                        Messages.ShowMessages("ERROR - Invalide Charackter", ConsoleColor.Red);
                    }
                    Messages.ShowMessages("Have a nice day professor. \n  \r \r  LOG OUT", ConsoleColor.Yellow);
                    Console.ResetColor();
                }
                else
                {
                    Messages.ShowMessages("ERROR - Incorect input", ConsoleColor.Red);
                }
            }
            else
            {
                Messages.ShowMessages("ERROR - Incorect input", ConsoleColor.Red);
            }
            Console.ReadLine();
        }