Ejemplo n.º 1
0
        //Create a new Course and assign to a Department
        private static void Q3()
        {
            string menu1        = "Please Enter New CourseID (4 Digits)";
            string courseID     = AskInput(menu1);
            string menu2        = "Please Enter New Course Title";
            string courseTitle  = AskInput(menu2);
            string menu3        = "Please Enter Course Credit";
            string courseCredit = AskInput(menu3);

            listData.ListDepartment();
            string menu4        = "Please Choose DepartmentID";
            string departmentID = AskInput(menu4);
            var    newCourse    = new Course();

            newCourse.CourseID     = short.Parse(courseID);
            newCourse.Title        = courseTitle;
            newCourse.Credits      = byte.Parse(courseCredit);
            newCourse.DepartmentID = byte.Parse(departmentID);
            db.Course.Add(newCourse);
            db.SaveChanges();
            listData.ListCourse();
            Success();
        }