public async Task <IActionResult> Create([Bind("ID,Name")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("ID,Name,Surname,Address,Qualification,ContactNo,DepartmentID")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.DepartmentID = new SelectList(_context.Department, "ID", "Name", employee.DepartmentID); return(View(employee)); }