Пример #1
0
        public void DeleteStudent(IRepository repository)
        {
            //Obtain the Id of the Student
            Student student = new Student();
            var     id      = ObtainIdOfStudent(student);

            //Search if exisits and print the Student found
            var studentToDelete = repository.GetById(id);

            PrintInConsole.PrintStudentDelete(studentToDelete);
            ConditionToDeleteTheStudent(repository, studentToDelete);
        }
Пример #2
0
 public void GetAllStudents(IRepository repository)
 {
     try
     {
         var students = repository.GetAll();
         PrintInConsole.PrintAllStudents(students);
         MenusController.MenuCrud(repository);
     }
     catch (CustomException e)
     {
         System.Console.WriteLine(Console_Resources.ErrorControl, e);
     }
 }
Пример #3
0
 public void AddStudent(IRepository repository)
 {
     try
     {
         Student student = new Student();
         ObtainStudent(student);
         repository.Add(student);
         PrintInConsole.PrintStudentAdded(student);
         MenusController.MenuCrud(repository);
     }
     catch (CustomException e)
     {
         System.Console.WriteLine(Console_Resources.ErrorControl, e);
     }
 }
Пример #4
0
        public void GetStudentById(IRepository repository)
        {
            try
            {
                //Obtain the Id of the Student
                Student student = new Student();
                var     id      = ObtainIdOfStudent(student);

                //Search if exisits and print the Student found
                PrintInConsole.PrintStudentSearch(repository.GetById(id));

                //Return to menu
                MenusController.MenuCrud(repository);
            }
            catch (CustomException e)
            {
                System.Console.WriteLine(Console_Resources.ErrorControl, e);
            }
        }
Пример #5
0
        public void UpdateStudent(IRepository repository)
        {
            //Obtain all the Students to choose what Student Modify
            Student student  = new Student();
            var     students = repository.GetAll();

            PrintInConsole.PrintAllStudents(students);

            //Obtain the Id of the student to choose what Student Modify
            System.Console.WriteLine(Console_Resources.IntroduceTheStudentToModify);
            var studentIntroduced = Convert.ToInt32(System.Console.ReadLine());

            //Obtain the student chose modified.
            ObtainData(student);

            //Update the student
            repository.UpdateStudent(studentIntroduced, student);

            //Print the Student Modified
            PrintInConsole.PrintStudentModified(student);

            //Return to menu
            MenusController.MenuCrud(repository);
        }