public IHttpActionResult PutDepartment(int id, Department department) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != department.DeptID) { return(BadRequest()); } db.Entry(department).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UpdateStudent(int id, string name, DateTime birthday, int class_id) { var db = new MyDataBaseEntities(); var student = db.Student.Find(id); student.Name = name; student.Birthday = birthday; student.Class_id = class_id; db.Entry(student).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
// Edit Employee public IHttpActionResult PutEmployee(Employee employee) { db.Entry(employee).State = EntityState.Modified; return(Ok(employee)); }
// Edit Department public IHttpActionResult PutDepartment(Department department) { db.Entry(department).State = EntityState.Modified; return(Ok(department)); }