public async Task <IActionResult> PutSEmployee([FromRoute] string id, [FromBody] SEmployee sEmployee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sEmployee.EmpCode) { return(BadRequest()); } _context.Entry(sEmployee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SEmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostSEmployee([FromBody] SEmployee sEmployee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SEmployee.Add(sEmployee); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (SEmployeeExists(sEmployee.EmpCode)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetSEmployee", new { id = sEmployee.EmpCode }, sEmployee)); }