public ActionResult Create([Bind(Include = "ID,EnrollmentDate,FirstName,LastName")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
        public ActionResult Create([Bind(Include = "InstructorID,Location")] OfficeAssignment officeAssignment)
        {
            if (ModelState.IsValid)
            {
                db.OfficeAssigments.Add(officeAssignment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.InstructorID = new SelectList(db.Instructors, "ID", "FirstName", officeAssignment.InstructorID);
            return(View(officeAssignment));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "DepartmentID,Name,Budget,StartDate,InstructorID")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.InstructorID = new SelectList(db.Instructors, "ID", "FirstName", department.InstructorID);
            return(View(department));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "CourseID,Title,Credits,DepartmentID")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", course.DepartmentID);
            return(View(course));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "ID,HireDate,FirstName,LastName")] Instructor instructor)
        {
            if (ModelState.IsValid)
            {
                db.Instructors.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID = new SelectList(db.OfficeAssigments, "InstructorID", "Location", instructor.ID);
            return(View(instructor));
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "InstructorID,CourseID")] Teaching teaching)
        {
            if (ModelState.IsValid)
            {
                db.Teachings.Add(teaching);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID     = new SelectList(db.Courses, "CourseID", "Title", teaching.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "ID", "FirstName", teaching.InstructorID);
            return(View(teaching));
        }
        public ActionResult Create([Bind(Include = "EnrollmentID,StudentID,CourseID,Grade")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                db.Enrollments.Add(enrollment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID  = new SelectList(db.Courses, "CourseID", "Title", enrollment.CourseID);
            ViewBag.StudentID = new SelectList(db.Students, "ID", "FirstName", enrollment.StudentID);
            return(View(enrollment));
        }
Exemple #8
0
 public void CreateStudent(CourseManagementSystemDbContext context)
 {
     if (!context.Students.Any())
     {
         var students = new List <Student>
         {
             new Student
             {
                 FirstName      = "Trong An",
                 LastName       = "Nguyen",
                 EnrollmentDate = DateTime.Parse("2016-01-01")
             },
             new Student
             {
                 FirstName      = "Thien Hieu",
                 LastName       = "Nguyen",
                 EnrollmentDate = DateTime.Parse("2016-01-02")
             },
             new Student
             {
                 FirstName      = "Tuan Nghia",
                 LastName       = "Tran",
                 EnrollmentDate = DateTime.Parse("2016-01-03")
             },
         };
         students.ForEach(s => context.Students.Add(s));
         context.SaveChanges();
     }
 }
Exemple #9
0
 //Thieu dien departmentn Id cung sinh ra loi, nhung khong do dinh nghia ma do Â
 public void CreateCourses(CourseManagementSystemDbContext context)
 {
     if (!context.Courses.Any())
     {
         var courses = new List <Course>
         {
             new Course {
                 CourseID = 1000, Title = "Submit 2", Credits = 10, DepartmentID = 1
             },
             new Course {
                 CourseID = 1001, Title = "Enterprice web software development", Credits = 11, DepartmentID = 2
             },
             new Course {
                 CourseID = 1002, Title = "Application development for mobile", Credits = 12, DepartmentID = 2
             },
             new Course {
                 CourseID = 1003, Title = "Interaction design", Credits = 13, DepartmentID = 2
             },
             new Course {
                 CourseID = 1004, Title = "Development framework", Credits = 14, DepartmentID = 2
             },
             new Course {
                 CourseID = 1005, Title = "Programming framework", Credits = 15, DepartmentID = 2
             },
             new Course {
                 CourseID = 1006, Title = "Database engineering", Credits = 16, DepartmentID = 2
             },
         };
         courses.ForEach(s => context.Courses.Add(s));
         context.SaveChanges();
     }
 }
Exemple #10
0
 public void CreateDepartments(CourseManagementSystemDbContext context)
 {
     if (!context.Departments.Any())
     {
         var departments = new List <Department>
         {
             new Department()
             {
                 Name         = "English Faculty",
                 Budget       = 1000,
                 StartDate    = DateTime.Parse("2010-01-01"),
                 InstructorID = 1
             },
             new Department()
             {
                 Name         = "Information Technology Faculty",
                 Budget       = 1000,
                 StartDate    = DateTime.Parse("2010-01-01"),
                 InstructorID = 2
             }
         };
         departments.ForEach(d => context.Departments.Add(d));
         context.SaveChanges();
     }
 }
Exemple #11
0
 public void CreateTeaching(CourseManagementSystemDbContext context)
 {
     if (!context.Teachings.Any())
     {
         var courses = new List <Teaching>
         {
             new Teaching {
                 CourseID = 1000, InstructorID = 1
             },
         };
         courses.ForEach(t => context.Teachings.Add(t));
         context.SaveChanges();
     }
 }
Exemple #12
0
        public void CreateOfficeOfficeAssigments(CourseManagementSystemDbContext context)
        {
            if (!context.OfficeAssigments.Any())
            {
                var officeAssignments = new List <OfficeAssignment>
                {
                    new OfficeAssignment {
                        InstructorID = 1, Location = "Office A"
                    },
                    new OfficeAssignment {
                        InstructorID = 2, Location = "Office B"
                    }
                };

                officeAssignments.ForEach(o => context.OfficeAssigments.Add(o));
                context.SaveChanges();
            }
        }
Exemple #13
0
 public void CreateEnrollments(CourseManagementSystemDbContext context)
 {
     if (!context.Enrollments.Any())
     {
         var enrollments = new List <Enrollment>
         {
             new Enrollment {
                 StudentID = 1, CourseID = 1000, Grade = Grade.Morning
             },
             new Enrollment {
                 StudentID = 1, CourseID = 1001, Grade = Grade.Morning
             },
             new Enrollment {
                 StudentID = 1, CourseID = 1002, Grade = Grade.Morning
             },
             new Enrollment {
                 StudentID = 2, CourseID = 1000
             }
         };
         enrollments.ForEach(s => context.Enrollments.Add(s));
         context.SaveChanges();
     }
 }
Exemple #14
0
 public void Createinstructors(CourseManagementSystemDbContext context)
 {
     if (!context.Instructors.Any())
     {
         var instructors = new List <Instructor>
         {
             new Instructor {
                 FirstName = "Nga", LastName = "Pham", HireDate = DateTime.Parse("2006-01-01")
             },
             new Instructor
             {
                 FirstName = "Van Vung",
                 LastName  = "Pham",
                 HireDate  = DateTime.Parse("2006-01-02")
             },
             new Instructor
             {
                 FirstName = "Thuy Duong",
                 LastName  = "Pham",
                 HireDate  = DateTime.Parse("2006-01-03")
             },
             new Instructor {
                 FirstName = "Jaya", LastName = "Jaya", HireDate = DateTime.Parse("2006-01-04")
             },
             new Instructor
             {
                 FirstName = "Tung Son",
                 LastName  = "Ngo",
                 HireDate  = DateTime.Parse("2006-01-05")
             },
         };
         instructors.ForEach(s => context.Instructors.Add(s));
         context.SaveChanges();
     }
     ;
 }