public async Task <IActionResult> Edit(int id, [Bind("Id,EmployeeId,PositionId,WorkStartDate,WorkEndDate,FacultyId")] EmplPosHistory emplPosHistory) { if (id != emplPosHistory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(emplPosHistory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmplPosHistoryExists(emplPosHistory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "FullName", emplPosHistory.EmployeeId); ViewData["FacultyId"] = new SelectList(_context.Faculties, "Id", "Name", emplPosHistory.FacultyId); ViewData["PositionId"] = new SelectList(_context.Positions, "Id", "Name", emplPosHistory.PositionId); return(View(emplPosHistory)); }
public async Task <IActionResult> Create([Bind("Id,EmployeeId,PositionId,WorkStartDate,WorkEndDate,FacultyId")] EmplPosHistory emplPosHistory) { if (ModelState.IsValid) { _context.Add(emplPosHistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "FullName", emplPosHistory.EmployeeId); ViewData["FacultyId"] = new SelectList(_context.Faculties, "Id", "Name", emplPosHistory.FacultyId); ViewData["PositionId"] = new SelectList(_context.Positions, "Id", "Name", emplPosHistory.PositionId); return(View(emplPosHistory)); }