// PUT api/EmployeeAPI/5 public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.EmpNo) { return(BadRequest()); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Delete(int id) { var emdel = em.Newempregs.Where(x => x.Empid == id).FirstOrDefault(); em.Entry(emdel).State = System.Data.Entity.EntityState.Deleted; em.SaveChanges(); return(Ok()); }
public ActionResult Edit([Bind(Include = "ID,First,Last,email,position")] emp emp) { if (ModelState.IsValid) { db.Entry(emp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emp)); }