public async Task <IActionResult> Edit(int id, [Bind("PlaneId,DepartmentName")] PlaneDepartment planeDepartment) { if (id != planeDepartment.PlaneId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(planeDepartment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlaneDepartmentExists(planeDepartment.PlaneId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentName"] = new SelectList(_context.Department, "Name", "Name", planeDepartment.DepartmentName); ViewData["PlaneId"] = new SelectList(_context.Plane, "PlaneId", "PlaneId", planeDepartment.PlaneId); return(View(planeDepartment)); }
public async Task <IActionResult> Create([Bind("PlaneId,DepartmentName")] PlaneDepartment planeDepartment) { if (ModelState.IsValid) { _context.Add(planeDepartment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentName"] = new SelectList(_context.Department, "Name", "Name", planeDepartment.DepartmentName); ViewData["PlaneId"] = new SelectList(_context.Plane, "PlaneId", "PlaneId", planeDepartment.PlaneId); return(View(planeDepartment)); }