public async Task <IActionResult> Create([Bind("DepartmentId,Name")] DepartmentModel departmentModel) { if (ModelState.IsValid) { _context.Add(departmentModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(departmentModel)); }
public async Task <IActionResult> Create([Bind("EmployeeId,FirstName,LastName,EmailAddress,PhoneNumber,DepartmentId")] EmployeeModel employeeModel) { if (ModelState.IsValid) { _context.Add(employeeModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Name", employeeModel.DepartmentId); return(View(employeeModel)); }