public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,EmployeeName,PositionID,ProfileID")] Tbl_Employees tbl_Employees) { if (id != tbl_Employees.EmployeeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tbl_Employees); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Tbl_EmployeesExists(tbl_Employees.EmployeeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PositionID"] = new SelectList(_context.Positions, "PositionID", "PositionID", tbl_Employees.PositionID); ViewData["ProfileID"] = new SelectList(_context.Profiles, "ProfileID", "ProfileID", tbl_Employees.ProfileID); return(View(tbl_Employees)); }
public async Task <IActionResult> PutTbl_Employees([FromRoute] int id, [FromBody] Tbl_Employees tbl_Employees) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_Employees.EmployeeID) { return(BadRequest()); } _context.Entry(tbl_Employees).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Tbl_EmployeesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostTbl_Employees([FromBody] Tbl_Employees tbl_Employees) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Empleoyees.Add(tbl_Employees); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTbl_Employees", new { id = tbl_Employees.EmployeeID }, tbl_Employees)); }
public async Task <IActionResult> Create([Bind("EmployeeID,EmployeeName,PositionID,ProfileID")] Tbl_Employees tbl_Employees) { if (ModelState.IsValid) { _context.Add(tbl_Employees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PositionID"] = new SelectList(_context.Positions, "PositionID", "PositionID", tbl_Employees.PositionID); ViewData["ProfileID"] = new SelectList(_context.Profiles, "ProfileID", "ProfileID", tbl_Employees.ProfileID); return(View(tbl_Employees)); }