コード例 #1
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);
     }
 }
コード例 #2
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);
     }
 }
コード例 #3
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);
            }
        }
コード例 #4
0
        private void ConditionToDeleteTheStudent(IRepository repository, Student student)
        {
            var userChoice = System.Console.ReadLine();

            if (userChoice.Equals("y"))
            {
                repository.DeleteStudent(student.StudentId);
                System.Console.WriteLine(Console_Resources.DeletedStudent);
                MenusController.MenuCrud(repository);
            }
            else if (userChoice.Equals("n"))
            {
                MenusController.MenuCrud(repository);
            }
            else
            {
                System.Console.WriteLine(Console_Resources.InvalidOption);
                ConditionToDeleteTheStudent(repository, student);
            }
        }
コード例 #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);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: JuanjoAvila/ReadFormats
 static void Main(string[] args)
 {
     MenusController.Init();
 }