public ActionResult Create([Bind(Include = "Id,FirstName,Email,PhoneNumber,DepartmentId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                m_repo.UpdateEmployee(employee);
                m_repo.SaveEmployee(employee);

                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(m_repo.GetAllDepartments(), "Id", "Name", employee.DepartmentId);
            return(View(employee));
        }
示例#2
0
        public ActionResult Edit(int id, Employee employee)
        {
            try
            {
                // TODO: Add update logic here

                m_repo.UpdateEmployee(employee);

                m_repo.DeleteEmployee(m_repo.GetEmployeeById(id));     //magic line of workingness

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }