public static StudentDirectory LoadStudentDirectory()
        {
            ObservableCollection <Student> students = new ObservableCollection <Student>();
            StudentDirectory studentDirectory       = new StudentDirectory();

            students = new ObservableCollection <Student>();

            string[] names = { "José Luis", "Miguel Ángel", "José Francisco", "Jesús Antonio",
                               "Sofía",     "Camila",       "Valentina",      "Isabella", "Ximena" };
            string[] lastNames = { "Hernández", "García", "Martínez", "López", "González" };

            Random rdn = new Random(DateTime.Now.Millisecond);

            students = new ObservableCollection <Student>();

            for (int i = 0; i < 20; i++)
            {
                Student student = new Student();
                student.Name     = names[rdn.Next(0, 8)];
                student.LastName = $"{lastNames[rdn.Next(0, 5)]} {lastNames[rdn.Next(0, 5)]}";
                string group = rdn.Next(456, 458).ToString();
                student.Group         = group;
                student.StudentNumber = rdn.Next(12384748, 32384748).ToString();
                student.Average       = rdn.Next(100, 1000) / 10;

                students.Add(student);
            }

            studentDirectory.Students = students;

            return(studentDirectory);
        }
Exemple #2
0
        public static StudentDirectory LoadStudentDirectory()
        {
            StudentDirectory studentDirectory = new StudentDirectory();
            ObservableCollection <Student> students;

            string[] names = { "José Luiz", "Miguel Angelo", "José Francisco", "Jesus Antonio", "Sofia", "Camila", "Valentina", "Isabella", "Ximena" };

            string[] lastNames = { "Fernandes", "Garcia", "Matins", "Lopes", "Gonzales" };

            Random random = new Random(DateTime.Now.Millisecond);

            students = new ObservableCollection <Student>();

            for (int i = 0; i < 20; i++)
            {
                Student student = new Student();
                student.Name          = names[random.Next(0, 8)];
                student.Lastname      = $"{lastNames[random.Next(0, 5)]} {lastNames[random.Next(0, 5)]}";
                student.Group         = random.Next(456, 458).ToString();
                student.StudentNumber = random.Next(12384748, 32384748).ToString();
                student.Average       = random.Next(100, 1000) / 10;
                students.Add(student);
            }
            studentDirectory.Students = students;
            return(studentDirectory);
        }
        public static StudentDirectory loadStudentDirectory()
        {
            DatabaseManager dbManager = new DatabaseManager();
            ObservableCollection <Student> students = new ObservableCollection <Student>(dbManager.GetAllItems <Student>());
            StudentDirectory studentDirectory       = new StudentDirectory();

            if (students.Any())
            {
                studentDirectory.Students = students;
                return(studentDirectory);
            }

            students = new ObservableCollection <Student>();

            string[] names =
            {
                "Andres Felipe",
                "Sebastian",
                "Alvaro",
                "Ediney",
                "Jose Miguel",
                "Daniela",
                "Camila",
                "Carolina"
            };

            string[] lastName =
            {
                "Polo",
                "Estupiñan",
                "Vargas",
                "Perez",
                "Galan"
            };

            Random rdn = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < 20; i++)
            {
                Student student = new Student();
                student.Name          = names[rdn.Next(0, 7)];
                student.LastName      = lastName[rdn.Next(0, 4)];
                student.Group         = rdn.Next(456, 458).ToString();
                student.StudentNumber = rdn.Next(12384748, 32384748).ToString();
                student.Key           = student.StudentNumber;
                student.Average       = rdn.Next(100, 1000) / 10;
                students.Add(student);
                dbManager.SaveValue <Student>(student);
            }
            studentDirectory.Students = students;
            return(studentDirectory);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            StudentDirectory studentDirectory = new StudentDirectory();
            bool             again            = true;

            Console.Write("Welcome to the class. ");
            while (again == true)
            {
                Console.WriteLine("Which student would you like to learn more about? " +
                                  "(enter a number 1-" + studentDirectory.Directory.Count() + "): ");
                Student selectedStudent = SelectStudent(studentDirectory);
                Console.WriteLine("What would you like to know about this student? " +
                                  @"enter ""hometown"", or ""favorite food"": ");
                SelectInfo(selectedStudent);
                again = Again();
            }
        }
Exemple #5
0
        public void StudentDirectoryTestJson()
        {
            List <Student> students = new List <Student>
            {
                new Student("nabeel", "234342"),
                new Student("yin", "3423423"),
                new Student("bill", "4234"),
                new Student("sashi", "545454"),
                new Student("jon", "53453453")
            };
            StudentDirectory p = new StudentDirectory(students);

            SimplTypesScope simplTypesScope = SimplTypesScope.Get("studentDir", typeof(Person),
                                                                  typeof(Student), typeof(StudentDirectory));

            TestMethods.TestSimplObject(p, simplTypesScope, Format.Json);
        }
 static void Main(string[] args)
 {
     StudentDirectory database = new StudentDirectory();
     var sortedStudents = database.Students.OrderByDescending(firstName => firstName.FirstName).ThenBy(lastname => lastname.LastName);
     Console.WriteLine("Sorted by using of Lambda expression");
     Console.WriteLine();
     foreach (var student in sortedStudents)
     {
         Console.WriteLine("{0} {1} {2}",student.FirstName, student.LastName, student.FacultyNumber);
     }
     var sortStudentsQuery = database.Students.SortStudentsQuery();
     Console.WriteLine();
     Console.WriteLine("Sorted by using of LINQ Query");
     Console.WriteLine();
     foreach (var student in sortStudentsQuery)
     {
         Console.WriteLine("{0} {1} {2}",student.FirstName, student.LastName, student.FacultyNumber);
     }
 }
Exemple #7
0
        public static StudentDirectory LoadStudentDirectory()
        {
            DatabaseManager dbManager = new DatabaseManager();
            ObservableCollection <Student> students = new ObservableCollection <Student>(dbManager.GetAllItems <Student>());
            StudentDirectory studentDirectory       = new StudentDirectory();

            if (students.Any())
            {
                studentDirectory.Students = students;
                return(studentDirectory);
            }

            students = new ObservableCollection <Student>();

            string[] names = { "André", "Luís", "Marcos", "José" };

            string[] lastNames = { "André", "Luís", "Marcos", "José" };

            Random rdn = new Random(DateTime.Now.Millisecond);

            students = new ObservableCollection <Student>();

            for (int i = 0; i < 20; i++)
            {
                Student student = new Student();
                student.Name     = names[rdn.Next(0, 4)];
                student.LastName = lastNames[rdn.Next(0, 4)];

                string group = rdn.Next(456, 458).ToString();
                student.Group         = group;
                student.StudentNumber = rdn.Next(123456, 3223423).ToString();
                student.Key           = student.StudentNumber;
                student.Average       = rdn.Next(100, 1000) / 10;

                students.Add(student);
                dbManager.SaveValue(student);
            }

            studentDirectory.Students = students;
            return(studentDirectory);
        }
        public static StudentDirectory LoadStudentDirectory()
        {
            DatabaseManager db = new DatabaseManager();
            ObservableCollection <Student> students = new ObservableCollection <Student>(db.GetAllItens <Student>());
            StudentDirectory studentDirectory       = new StudentDirectory();

            if (students.Any())
            {
                studentDirectory.Students = students;
                return(studentDirectory);
            }

            students = new ObservableCollection <Student>();

            string[] name      = { "Jose", "Pedro", "Maria", "Felipe", "Ana", "Maria" };
            string[] sobrenome = { "Silva", "Ribeiro", "Santos", "Garcia", "Gonzalez" };

            Random rd = new Random(DateTime.Now.Millisecond);

            students = new ObservableCollection <Student>();

            for (int i = 0; i < 20; i++)
            {
                Student estudante = new Student();
                estudante.Nome      = name[rd.Next(0, 5)];
                estudante.Sobrenome = $"{sobrenome[rd.Next(0,5)]}{sobrenome[rd.Next(0, 5)] }";
                string classe = rd.Next(456, 458).ToString();
                estudante.Classe = classe;
                estudante.Numero = rd.Next(12384748, 32384748).ToString();
                estudante.Media  = rd.Next(100, 1000) / 10;
                estudante.Key    = estudante.Numero;

                students.Add(estudante);

                db.SaveValue <Student>(estudante);
            }

            studentDirectory.Students = students;
            return(studentDirectory);
        }
Exemple #9
0
        public static StudentDirectory LoadStudentDirectory()
        {
            Student          student;
            StudentDirectory studentDirectory       = new StudentDirectory();
            DatabaseManager  dbManager              = new DatabaseManager();
            ObservableCollection <Student> students = new ObservableCollection <Student>(dbManager.GetList <Student>());
            Random random = new Random(DateTime.Now.Millisecond);

            if (students.Any())
            {
                studentDirectory.Students = students;
                return(studentDirectory);
            }

            students = new ObservableCollection <Student>();

            string[] names     = { "Andrés", "Alejandro", "Fabián", "Sebastián", "Carlos", "César", "Héctor", "Germán" };
            string[] lastNames = { "Rosales", "Cadavid", "Díaz", "Delgado", "Carvajal", "Ramírez", "Arias", "Pardo" };

            for (byte i = 0; i < 20; i++)
            {
                student = new Student()
                {
                    Name          = names[random.Next(0, names.Length - 1)],
                    LastName      = lastNames[random.Next(0, lastNames.Length - 1)],
                    Group         = random.Next(456, 458).ToString(),
                    StudentNumber = random.Next(12345678, 345678900).ToString(),
                    Key           = random.Next(12345678, 345678900).ToString(),
                    Average       = random.Next(100, 1000) / 10
                };
                dbManager.Save <Student>(student);
                students.Add(student);
            }

            studentDirectory.Students = students;
            return(studentDirectory);
        }
Exemple #10
0
        public static Student SelectStudent(StudentDirectory studentDirectory)
        {
            string idInput = Console.ReadLine().ToLower();
            int    id;

            try
            {
                id = Int32.Parse(idInput);
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("enter a number 1-" + studentDirectory.Directory.Count());
                return(SelectStudent(studentDirectory));
            }
            catch (OverflowException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.Message);
                Console.WriteLine("enter a number 1-" + studentDirectory.Directory.Count());
                return(SelectStudent(studentDirectory));
            }

            try
            {
                Console.WriteLine("Student " + id + " is " +
                                  studentDirectory.GetStudent(id).Name + ".");
                return(studentDirectory.GetStudent(id));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("That's not a student, try again.");
                return(SelectStudent(studentDirectory));
            }
        }
Exemple #11
0
 public StudentDirectoryVM()
 {
     IsBusy               = false;
     StudentDirectory     = new StudentDirectory();
     LoadDirectoryCommand = new Command(LoadDirectory, () => !IsBusy);
 }
Exemple #12
0
 public FormAssistControlPage()
 {
     InitializeComponent();
     BindingContext = new StudentDirectory();
 }