public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.id) { 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 void Put(int id, Employee e) { try { Employee GetEmployee = dbcontext.Employees.Where(s => s.id == id).FirstOrDefault(); GetEmployee.age = e.age; GetEmployee.firstName = e.firstName; GetEmployee.gender = e.gender; GetEmployee.lastName = e.lastName; dbcontext.Entry(GetEmployee).State = EntityState.Modified; dbcontext.SaveChanges(); } catch (Exception ex) { throw ex; } }
public ActionResult Edit([Bind(Include = "id,firstName,lastName,age,gender")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit(Employee E) { if (ModelState.IsValid) { _pPECBdbModel.Entry(E).State = EntityState.Modified; _pPECBdbModel.SaveChanges(); return(RedirectToAction("Index")); } return(View(E)); }