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); } }
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); } }
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); } }
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); } }
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); }
static void Main(string[] args) { MenusController.Init(); }