Пример #1
0
 public IActionResult Employee([Bind("Id,FirstName,DepartmentId")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         _context.Add(employee);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["DepartmentId"] = new SelectList(_context.Set <Department>(), "DepartmentId", "Name", employee.DepartmentId);
     return(View(employee));
 }
 public IActionResult Department([Bind("DepartmentId,Name,BuildingId")] Department department)
 {
     if (ModelState.IsValid)
     {
         _context.Add(department);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["BuildingId"] = new SelectList(_context.Set <Building>(), "DepartmentId", "Name", department.BuildingId);
     return(View(department));
 }