示例#1
0
        public static void AddNewStudnet(Student student, StudentRespository studentRepository)
        {
            studentRepository = new StudentRespository();
            student           = new Student();


            System.Console.Write("Student Id : ");
            student.StudenId = int.Parse(System.Console.ReadLine());
            System.Console.Write("Name       : ");
            student.Name = System.Console.ReadLine();
            System.Console.Write("Surname    : ");
            student.Surname = System.Console.ReadLine();
            System.Console.Write("Birthday   : ");
            student.Birthday = DateTime.Parse(System.Console.ReadLine()).Date;

            if (studentRepository.IsExistData())
            {
                if (studentRepository.FoundStudentById(student).StudenId != student.StudenId)
                {
                    studentRepository.AddStudent(student);
                    System.Console.WriteLine("Adding new Student!!");
                }
                else
                {
                    System.Console.WriteLine("Student already exist!!");
                }
            }
            else
            {
                studentRepository.AddStudent(student);
                System.Console.WriteLine("Adding new Student!!");
            }

            System.Console.ReadKey();
        }
示例#2
0
        public static bool SearchStudentById(Student student, StudentRespository studentRepository)
        {
            student           = new Student();
            studentRepository = new StudentRespository();
            string number  = null;
            bool   isFound = false;

            if (!studentRepository.IsExistData())
            {
                System.Console.WriteLine("Don't exist data!!");
                return(isFound);
            }
            else
            {
                do
                {
                    System.Console.Clear();
                    System.Console.Write("Insert number id of Student : ");
                    number   = System.Console.ReadLine();
                    isNumber = int.TryParse(number, out int valor);
                } while (!isNumber);

                student.StudenId = int.Parse(number);
                studentIdStatic  = student.StudenId;
                if (studentRepository.FoundStudentById(student) != student)
                {
                    System.Console.WriteLine("Student  not found!");
                    isFound = false;
                }
                else
                {
                    HeaderData();
                    System.Console.WriteLine(student.ToString());
                    System.Console.WriteLine("Student  found it!");
                    isFound = true;
                }

                System.Console.ReadKey();

                return(isFound);
            }
        }