// Create employee public int create(String firstname, String lastname, DateTime DOB, String contactNum, DateTime startDate, int dept, int depot, int role) { // Establishes model EmployeeModel employeeModel = new EmployeeModel(); // Holds the new employee Employee newEmployee = new Employee(); // Stored details for the employee newEmployee.Firstname = firstname; newEmployee.Lastname = lastname; newEmployee.DOB = DOB; newEmployee.ContactNumber = contactNum; newEmployee.Startdate = startDate; newEmployee.Dept = dept; newEmployee.Depot = depot; newEmployee.Role = role; // Adds the object to the database int employeeID = employeeModel.NewEmployee(newEmployee); // Return the employeeID return employeeID; }
// GET: Employee public ActionResult Index() { // Null handling if (Session["loggedInState"] == null) { return Redirect("/403.html"); } // Checks if logged in bool state = (bool)Session["loggedInState"]; if (state == true) { // Establishes employee model EmployeeModel employeeModel = new EmployeeModel(); // Holds the new employee Employee newEmployee = new Employee(); // Stored details for the employee newEmployee.Firstname = Request.Form[0]; newEmployee.Lastname = Request.Form[1]; newEmployee.DOB = DateTime.Parse(Request.Form[2]); newEmployee.ContactNumber = Request.Form[3]; newEmployee.Startdate = DateTime.Parse(Request.Form[4]); newEmployee.Dept = int.Parse(Request.Form[5]); newEmployee.Depot = int.Parse(Request.Form[6]); newEmployee.Role = int.Parse(Request.Form[7]); // Adds the object to the database employeeModel.NewEmployee(newEmployee); // Return created employee to view return View(newEmployee); } else { // If not logged in return Redirect("/login.html"); } }