public IActionResult Create([Bind("Id,Name,ContactPhoneNumber")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public IActionResult Create([Bind("Id,EmployeeId,DepartmentId,StartTime,EndTime,Date")] TimeRecord timeRecord) { if (ModelState.IsValid) { _context.Add(timeRecord); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "Id", "Id", timeRecord.DepartmentId); ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "Id", timeRecord.EmployeeId); return(View(timeRecord)); }