public async Task <IActionResult> Create([Bind("id,DepartmentName")] Departments departments) { if (ModelState.IsValid) { _context.Add(departments); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(departments)); }
public async Task <IActionResult> Create([Bind("id,FName,LName,Phone,Address,City,State,Zipcode,DepartmentID")] Employees employees) { if (ModelState.IsValid) { _context.Add(employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentID"] = new SelectList(_context.Departments, "id", "DepartmentName", employees.DepartmentID); return(View(employees)); }