示例#1
0
        public ActionResult DeleteOne(int studentId)
        {
            Student thisStudent = Student.Find(studentId);

            thisStudent.DeleteOne();

            return(RedirectToAction("StudentIndex"));
        }
示例#2
0
        public ActionResult Update(int id)
        {
            string  newName     = Request.Form["newname"];
            Student thisStudent = Student.Find(id);

            thisStudent.UpdateName(newName);
            return(RedirectToAction("StudentIndex"));
        }
示例#3
0
        public ActionResult AddCourse(int studentId)
        {
            Student student = Student.Find(studentId);
            Course  course  = Course.Find(Int32.Parse(Request.Form["course-id"]));

            student.AddCourse(course);

            return(View("Success"));
        }
        public ActionResult AddStudent(int courseId)
        {
            Course  course  = Course.Find(courseId);
            Student student = Student.Find(Int32.Parse(Request.Form["student-id"]));

            course.AddStudent(student);

            return(RedirectToAction("Success", "Home"));
        }
示例#5
0
        public void Test_Find_FindStudentInDatabase()
        {
            //Arrange
            Student testStudent = new Student("Jasper", "07/24/2017");

            testStudent.Save();

            //Act
            Student foundStudent = Student.Find(testStudent.GetId());

            //Assert
            Assert.Equal(testStudent, foundStudent);
        }
示例#6
0
        public void Test_FindFindsStudentInDatabase()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

            //Act
            Student result = Student.Find(testStudent.GetId());

            //Assert
            Assert.Equal(testStudent, result);
        }
示例#7
0
        public ActionResult StudentDetail(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Student selectedStudent           = Student.Find(id);

            List <Course> studentCourses = selectedStudent.GetCourses();
            List <Course> allCourses     = Course.GetAll();

            model.Add("student", selectedStudent);
            model.Add("studentCourses", studentCourses);
            model.Add("allCourses", allCourses);

            return(View("StudentDetails", model));
        }
示例#8
0
        public ActionResult StudentUpdateForm(int id)
        {
            Student thisStudent = Student.Find(id);

            return(View("StudentUpdate", thisStudent));
        }