public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.suburbID = new SelectList(db.Suburbs, "suburbID", "suburb1", employee.suburbID);
            return View(employee);
        }
        public void EmployeesController_Create_isNotValid()
        {
            Employee testEmployee = new Employee();
            testEmployee.employeeFirstName = "invalidEmployee";
            EmployeesController controller = new EmployeesController();
            controller.ModelState.AddModelError("", "error message");

            var result = controller.Create(testEmployee) as ViewResult;
            Employee resultEmployees = (Employee)result.Model;

            Assert.AreEqual("invalidEmployee", resultEmployees.employeeFirstName);
        }
        public void EmployeesController_Create_isValid()
        {
            Employee testEmployee = new Employee();
            testEmployee.employeeDepartment = "Sales";
            testEmployee.employeeEmail = "*****@*****.**";
            testEmployee.employeeStreet = "test street";
            testEmployee.employeeFirstName = "TestEmp";
            testEmployee.employeeLastName = "TestLast";

            EmployeesController controller = new EmployeesController();

            var result = (RedirectToRouteResult)controller.Create(testEmployee);

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
 public ActionResult Edit(Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.suburbID = new SelectList(db.Suburbs, "suburbID", "suburb1", employee.suburbID);
     return View(employee);
 }