// POST: Teacher/Filter/{}
        public ActionResult Filter(string name = null, string salaryLow = null, string salaryHigh = null, string hireDateLow = null, string hireDateHigh = null, string employeeNumber = null)
        {
            TeacherDataController controller     = new TeacherDataController();
            IEnumerable <Teacher> filterTeachers = controller.FilterTeachers(name, salaryLow, salaryHigh, hireDateLow, hireDateHigh, employeeNumber);

            return(View(filterTeachers));
        }
        public ActionResult UpdateTeacher(int id)
        {
            TeacherDataController controller = new TeacherDataController();
            Teacher newTeacher = controller.FindTeacher(id);

            return(View(newTeacher));
        }
        public ActionResult DeleteTeacher(int id)
        {
            TeacherDataController controller = new TeacherDataController();

            controller.DeleteTeacher(id);
            return(RedirectToAction("Filter"));
        }
        // GET: Teacher/List
        // Deprecated method : Please use Filter
        public ActionResult List(string searchKey = null)
        {
            TeacherDataController controller = new TeacherDataController();
            IEnumerable <Teacher> teachers   = controller.ListTeachers(searchKey);

            return(View(teachers));
        }
Esempio n. 5
0
        //GET : /Teacher/Update/{id}
        public ActionResult Update(int id)
        {
            TeacherDataController controller = new TeacherDataController();
            Teacher SelectedTeacher          = controller.GetTeacherInformation(id);

            return(View(SelectedTeacher));
        }
Esempio n. 6
0
        // GET: /Teacher/List
        public ActionResult List()
        {
            TeacherDataController controller = new TeacherDataController();
            IEnumerable <Teacher> Teachers   = controller.ListTeachers();

            return(View(Teachers));
        }
Esempio n. 7
0
        //GET : /Teacher/DeleteConfirm/{id}
        public ActionResult DeleteConfirm(int id)
        {
            TeacherDataController controller = new TeacherDataController();
            // Get teacher information
            Teacher teacher = controller.GetTeacherInformation(id);

            // Get course information associated to the teacher
            teacher.Classes = controller.GetTeacherClasses(id);
            return(View(teacher));
        }
Esempio n. 8
0
        public ActionResult Delete(int teacherId, int classCount)
        {
            TeacherDataController controller = new TeacherDataController();

            // Delete teacher
            controller.DeleteTeacher(teacherId);
            // if deleted teacher has classes associated, remove them
            if (classCount > 0)
            {
                controller.RemoveTeacherClasses(teacherId);
            }
            return(RedirectToAction("List"));
        }
Esempio n. 9
0
        public ActionResult Add([Bind(Include = "EmployeeNumber,HireDate,Salary,TeacherFname,TeacherLname")] Teacher newTeacher)
        {
            // validate the data (server-side)
            if (ModelState.IsValid)
            {
                TeacherDataController controller = new TeacherDataController();
                // pass newTeacher to AddTeacher and get the ID of the created teacher
                int teacherId = controller.AddTeacher(newTeacher);
                // Redirect to created teacher profile
                return(RedirectToAction($"Show/{teacherId}"));
            }

            return(View(newTeacher));
        }
        public ActionResult CreateTeacher(string teacherFName, string teacherLName, string empNumber, string salary, string teacherid = null, string hireDate = null)
        {
            Teacher newTeacher = new Teacher
            {
                teacherFname   = teacherFName,
                teacherLname   = teacherLName,
                employeeNumber = empNumber,
                salary         = salary,
                hireDate       = DateTime.Parse(hireDate)
            };
            TeacherDataController controller = new TeacherDataController();

            controller.CreateTeacher(newTeacher);
            return(RedirectToAction("Filter"));
        }
        public ActionResult UpdateTeacherChanges(string teacherFName, string teacherLName, string empNumber, string salary, string teacherid = null, string hireDate = null)
        {
            Teacher newTeacher = new Teacher
            {
                teacherFname   = teacherFName,
                teacherLname   = teacherLName,
                employeeNumber = empNumber,
                salary         = salary,
                hireDate       = DateTime.Parse(hireDate),
                teacherId      = Convert.ToInt32(teacherid)
            };
            TeacherDataController controller = new TeacherDataController();

            controller.UpdateTeacher(newTeacher);
            return(RedirectToAction("Show/" + teacherid));
        }
Esempio n. 12
0
 public ActionResult Update([Bind(Include = "EmployeeNumber,HireDate,Salary,TeacherFname,TeacherLname")] Teacher teacherInfo, int TeacherId)
 {
     // validate the data (server-side)
     if (ModelState.IsValid)
     {
         TeacherDataController controller = new TeacherDataController();
         // Update teacher
         teacherInfo.TeacherId = TeacherId;
         controller.UpdateTeacher(teacherInfo);
         // Redirect to updated teacher profile
         return(RedirectToAction($"Show/{TeacherId}"));
     }
     else
     {
         // on validation fail:- show last saved teacher information
         return(RedirectToAction($"Update/{TeacherId}"));
     }
 }
        // GET: Teacher/Show/{id}
        public ActionResult Show(int id)
        {
            TeacherDataController controller = new TeacherDataController();
            Teacher newTeacher = controller.FindTeacher(id);

            Classes NewSearchClass = new Classes
            {
                employeeNumber = Convert.ToString(newTeacher.employeeNumber)
            };

            ClassesDataController class_controller = new ClassesDataController();
            IEnumerable <Classes> filterClasses    = class_controller.FilterClasses(NewSearchClass);

            TeacherClass newTeacherClass = new TeacherClass
            {
                classes = filterClasses,
                teacher = newTeacher
            };

            return(View(newTeacherClass));
        }