Exemplo n.º 1
0
        //Delete a Student
        private static void Q6()
        {
            listData.ListStudent();
            string menu1     = "Please Enter Student ID to Delete Record";
            short  studentID = short.Parse(AskInput(menu1));
            byte   answer    = byte.Parse(AskInput("Do you really want to DELETE this Student?\n1:Yes\n0:No"));

            if (answer == 1)
            {
                var deleteStudent = db.StudentGrade.First(s => s.StudentID == studentID);
                db.StudentGrade.Remove(deleteStudent);
                var deletePerson = db.Person.First(p => p.PersonID == studentID);
                db.Person.Remove(deletePerson);
                db.SaveChanges();
                Success();
            }
            else
            {
                ResponseToMenu();
            }
        }