Exemplo n.º 1
0
        public ActionResult Add(Employee employee)
        {
            ViewBag.Action = "Add";
            var model = ModelState;

            if (model.IsValid)
            {
                em.Post(employee);
                return(RedirectToAction(nameof(Index)));
            }

            return(View("Add"));
        }
Exemplo n.º 2
0
        public ActionResult Add(Employee employee)
        {
            ViewBag.Action = "Add";
            var model = ModelState;

            if (model.IsValid)
            {
                em.Post(employee);
                return(RedirectToAction(nameof(Index)));
            }
            EmployeeViewModel employeeVM = new EmployeeViewModel
            {
                Departments = dm.getAll()
            };

            return(View("Add", employeeVM));
        }