//POST :/Teacher/Create
        /// <summary>
        /// This method is called when we submit the necessary information after the form is validated
        /// </summary>
        /// <param name="TeacherFname">Teacher's First Name</param>
        /// <param name="TeacherLname">Teacher's Last Name</param>
        /// <param name="EmployeeNumber">Employee Number</param>
        /// <param name="TeacherHireDate">Hiring date</param>
        /// <param name="TeacherSalary">Teacher's salary</param>
        /// <returns></returns>
        public ActionResult Create(string TeacherFname, string TeacherLname, string EmployeeNumber, string TeacherHireDate, Double TeacherSalary)
        {
            Debug.WriteLine(TeacherFname);
            Debug.WriteLine(TeacherLname);
            Debug.WriteLine(TeacherHireDate);
            Debug.WriteLine(TeacherSalary);
            //Creates a model for teacher object.
            Teacher NewTeacher = new Teacher();

            if (TeacherFname == "" || TeacherLname == "" || EmployeeNumber == "" || TeacherHireDate == "")
            {
                return(RedirectToAction("InvalidData"));
            }
            else
            {
                NewTeacher.TeacherFname    = TeacherFname;
                NewTeacher.TeacherLname    = TeacherLname;
                NewTeacher.TeacherHireDate = TeacherHireDate;
                NewTeacher.TeacherSalary   = TeacherSalary;
                NewTeacher.TeacherSalary   = TeacherSalary;
                NewTeacher.EmployeeNumber  = EmployeeNumber;

                // Invokes the AddTeacher method we defined in the API controller
                TeacherDataController controller = new TeacherDataController();
                controller.AddTeacher(NewTeacher);

                return(RedirectToAction("List"));
            }
        }
        /// <summary>
        /// The following method is used to delete a particular teacher entry
        /// </summary>
        /// <param name="id">Primary Key</param>
        /// <returns></returns>
        //Post : /Teacher/Delete/{id}
        public ActionResult Delete(int id)
        {
            //Creates a instance of Controller.
            TeacherDataController controller = new TeacherDataController();

            // Invokes the deleteTeacher method we defined in the API controller
            controller.deleteTeacher(id);

            //Once the delete is performed, redirecting the user to the List Teacher's view
            return(RedirectToAction("List"));
        }
        //GET : Teacher/DeleteConfirm/{id}
        /// <summary>
        /// This method is used to confirm deletion when the delete button is clicked.
        /// </summary>
        /// <param name="id">Primary Key.</param>
        /// <returns>A view with the teacher's name and a confirm delete message.</returns>
        public ActionResult DeleteConfirm(int id)
        {
            //Creates a instance of Controller.
            TeacherDataController controller = new TeacherDataController();

            // Invokes the FindTeacher method we defined in the API controller
            Teacher newTeacher = controller.FindTeacher(id);

            //Returns the required information
            return(View(newTeacher));
        }
        //GET : Teacher/List
        /// <summary>
        /// This gives us a list of all the teachers.
        /// </summary>
        /// <param name="SearchKey">First name/Last name or both.</param>
        /// <returns>A view with list of teacher objects</returns>
        public ActionResult List(string SearchKey = null)
        {
            //Connects using the TeacherData controller.
            TeacherDataController controller = new TeacherDataController();

            //Calls a method of TeacherData controller and stores the result in the Teacher object.
            IEnumerable <Teacher> Teachers = controller.ListTeachers(SearchKey);

            //Returns the list of teachers.
            return(View(Teachers));
        }
        /// <summary>
        /// This method is called when we want to update the information for a particular teacher.
        /// </summary>
        /// <param name="id">PRIMARY KEY OF THE TEACHER</param>
        /// <returns>Teacher Information</returns>

        //GET :/Teacher/Update/{id}
        public ActionResult Update(int id)
        {
            //Creates an instance of the data controller.
            TeacherDataController controller = new TeacherDataController();

            // Calling the FindTeacher method
            Teacher selectedTeacher = controller.FindTeacher(id);

            //Returns the details of the selected teacher
            return(View(selectedTeacher));
        }
        public ActionResult Update(int id, string TeacherFname, string TeacherLname, Double TeacherSalary)
        {
            Teacher TeacherInfo = new Teacher();

            if (TeacherFname == "" || TeacherLname == "")
            {
                return(RedirectToAction("InvalidData"));
            }
            else
            {
                TeacherInfo.TeacherId     = id;
                TeacherInfo.TeacherFname  = TeacherFname;
                TeacherInfo.TeacherLname  = TeacherLname;
                TeacherInfo.TeacherSalary = TeacherSalary;

                // Invoking the UpdateTeacher method we defined in the API controller
                TeacherDataController controller = new TeacherDataController();
                controller.UpdateTeacher(id, TeacherInfo);
                return(RedirectToAction("/Show/" + id));
            }
        }