Пример #1
0
        public ActionResult Add(AddEmplVM model)
        {
            if (!ModelState.IsValid)
            {
                //have to manually reload select list item list as nothing is coming back from model data
                model.Departments = GetDepartmentsSelectListItems();
                return(View(model)); //return them to add page on fail
            }

            Employee add = new Employee
            {
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                PhoneNum     = model.PhoneNum,
                DepartmentId = model.DeptId
            };

            EmplRepoStub.CreateEmployee(add);

            return(RedirectToAction("List")); //redirect them to list view on completion
        }