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));
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        // Edit Employee

        public IHttpActionResult PutEmployee(Employee employee)
        {
            db.Entry(employee).State = EntityState.Modified;
            return(Ok(employee));
        }
Exemplo n.º 4
0
        // Edit Department

        public IHttpActionResult PutDepartment(Department department)
        {
            db.Entry(department).State = EntityState.Modified;
            return(Ok(department));
        }