static void Main(string[] args) { var sqllib = new BcConnection(); sqllib.Connect(@"localhost", "EdDb", "trusted_connection=true"); MajorController.bcConnection = sqllib; var majors = MajorController.GetAllMajors(); foreach (var major in majors) { Console.WriteLine(major); } StudentController.bcConnection = sqllib; //var newStudent = new Student { // Id = 667, // FirstName = "Chuck", // LastName = "Intern of Darkness", // SAT = 000, // GPA = 4.0, // MajorId = null //}; //var success = StudentController.InsertStudent(newStudent); var student100 = StudentController.GetByPk(888); if (student100 == null) { Console.WriteLine("Student not found"); } else { Console.WriteLine(student100); } //student100.FirstName = "Jackie"; //student100.LastName = "Chan"; //var success = StudentController.UpdateStudent(student100); // //var studentToDelete = new Student { // Id = 777 //}; //success = StudentController.DeleteStudent(888); var students = StudentController.GetAllStudents(); foreach (var student in students) { Console.WriteLine(student); } var m = MajorController.GetByPk(1); foreach (var major in majors) { Console.WriteLine(m); } InstructorController.bcConnection = sqllib; var instructors = InstructorController.GetAllInstructors(); foreach (var instructor in instructors) { Console.WriteLine(instructor); } var instructPK = InstructorController.GetByPk(30); if (instructPK == null) { Console.WriteLine("Instructor not found"); } else { Console.WriteLine(instructPK); } ClassController.bcConnection = sqllib; var classes = ClassController.GetAllClasses(); foreach (var cla in classes) { Console.WriteLine(cla); } sqllib.Disconnect(); }
static void Main(string[] args) { var sqllib = new BcConnection(); sqllib.Connect(@"localhost\sqlexpress", "EdDb", "trusted_connection=true"); MajorController.bcConnection = sqllib; var Major = MajorController.GetMajorByPk(1); Console.WriteLine(Major); var majors = MajorController.GetAllMajors(); foreach (var major in majors) { Console.WriteLine(major); } // insert new major // var newMajor = new Major { // Id = 11 , // Description = "Graphics Design" , // MinSAT = 1100 // }; // var successmjins = MajorController.InsertMajor(newMajor); StudentController.bcConnection = sqllib; // setting property to instance var newStudent = new Student { Id = 885, Firstname = "Crazy", Lastname = "Eights", SAT = 600, GPA = 0.00, MajorId = 1 }; // var success = StudentController.InsertStudent(newStudent); var student = StudentController.GetStudentByPK(newStudent.Id); if (student == null) { Console.WriteLine("Student with primary key not found"); } else { Console.WriteLine(student); } student.Firstname = "Charlie"; student.Lastname = "Chan"; var success = StudentController.UpdateStudent(student); /* * var studentToDelete = new Student { * Id = 885 * }; * success = StudentController.DeleteStudent(885); */ var students = StudentController.GetAllStudents(); foreach (var student0 in students) { Console.WriteLine(student0); } sqllib.Disconnect(); }
static void Main(string[] args) { var sqllib = new BcConnection(); sqllib.Connect(@"localhost\sqlexpress", "EdDb", "trusted_connection=true"); StudentController.bcConnection = sqllib; MajorController.bcConnection = sqllib; InstructorController.bcConnection = sqllib; #region Instructor methods var instructors = InstructorController.GetAllInstructors(); foreach (var i in instructors) { Console.WriteLine(i); } var instructor = InstructorController.GetInstructorByPk(10); if (instructor == null) { Console.WriteLine("Instructor not found!"); } else { Console.WriteLine(instructor); } #endregion #region Major Controller methods var major = MajorController.GetMajorByPK(1); if (major == null) { Console.WriteLine("Major not found!"); } else { Console.WriteLine(major); } var majors = MajorController.GetAllMajors(); foreach (var m in majors) { Console.WriteLine(m); } #endregion #region Student Controller methods //var newStudent = new Student { // Id = 999, // Firstname = "Lazy", // Lastname = "Larry", // SAT = 1600, // GPA = 4.0, // MajorId = 3 //}; //var success = StudentController.InsertStudent(newStudent); var student = StudentController.GetStudentByPk(888); if (student == null) { Console.WriteLine("Student not found"); } else { Console.WriteLine(student); } //var studentToDelete = new Student { // Id = 999 //}; //var success = StudentController.DeleteStudent(999); //student.Firstname = "Charlie"; //student.Lastname = "Chan"; //var success = StudentController.UpdateStudent(student); var students = StudentController.GetAllStudents(); foreach (var student0 in students) { Console.WriteLine(student0); } #endregion sqllib.Disconnect(); }