public async Task <IActionResult> Create([Bind("BuildingId,Name")] Building building) { if (ModelState.IsValid) { _context.Add(building); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(building)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,DepartmentId")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Set <Department>(), "DepartmentId", "Name", employee.DepartmentId); return(View(employee)); }
public async Task <IActionResult> Create([Bind("DepartmentId,Name,BuildingId")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BuildingId"] = new SelectList(_context.Set <Building>(), "BuildingId", "Name", department.BuildingId); return(View(department)); }