Пример #1
0
        static void Main(string[] args)
        {
            string headerText = "Student List";

            DisplayMethods.DisplayHeader(headerText);

            StudentList.ListStudents();

            Console.Write("Select ID to view details: ");

            string choice    = Console.ReadLine();
            int    choiceInt = 0;

            Int32.TryParse(choice, out choiceInt);

            StudentDetails.CourseDetailsView(choiceInt);


            Console.ReadLine();
        }
Пример #2
0
        public static void CourseDetailsView(int id)
        {
            Console.Clear();
            DisplayMethods.DisplayHeader("Details of Student");


            using (var _context = new SchoolContext())
            {
                // Display the studetns name and details
                var students = _context.Students.Where(s => s.ID == id);
                foreach (var student in students)
                {
                    Console.WriteLine("Lastname: " + student.LastName);
                    Console.WriteLine("Firstname: " + student.FirstMidName);
                    Console.WriteLine("Enrollment Date: {0}", student.EnrollmentDate.ToLongDateString());
                    Console.WriteLine();
                    Console.WriteLine("Course Title\t\tGrade");
                }

                // Display the Course Title and Grade
                var enrollments = _context.Enrollments.Where(s => s.StudentID == id);

                var courses = from c in _context.Courses
                              join e in enrollments
                              on c.CourseID equals e.CourseID
                              select new
                {
                    Title = c.Title,
                    Grade = e.Grade
                };

                foreach (var item in courses)
                {
                    Console.WriteLine("{0}\t\t{1}", item.Title, item.Grade);
                }
                Console.WriteLine("Press <Enter> to Return to List");

                _context.Dispose();
            }
        }