Exemplo n.º 1
0
        //Ability to Update a Student record
        private static void Q8()
        {
            listData.ListStudent();
            string menu1     = "Please input the ID of the student you want to update.";
            int    studentID = Int32.Parse(AskInput(menu1));

            listData.ListStudentGradeById(studentID);
            string menu2  = "Are you sure you need to update?\n1.YES\n0.No";
            byte   answer = byte.Parse(AskInput(menu2));

            if (answer == 1)
            {
                int enrollmentID = Int32.Parse(AskInput("Please choose enrollment ID"));
                listData.ListCourse();
                string courseID = AskInput("Please update the courseID");
                string grade    = AskInput("Please update Grade");
                var    query    = db.StudentGrade.First(s => s.EnrollmentID == enrollmentID);
                if (query != null)
                {
                    query.CourseID = short.Parse(courseID);
                    query.Grade    = decimal.Parse(grade);
                    db.SaveChanges();
                    Success();
                }
            }
            else
            {
                ResponseToMenu();
            }
        }