// DELETE: api/Employee/5
 public void Delete(int id)
 {
     using (database_for_practiceEntities entities = new database_for_practiceEntities())
     {
         entities.EmployeeDatas.Remove(entities.EmployeeDatas.ToList().FirstOrDefault(e => e.ID == id));
         entities.SaveChanges();
     }
 }
 // POST: api/Employee
 public EmployeeData Post([FromBody] EmployeeData value)
 {
     using (database_for_practiceEntities entities = new database_for_practiceEntities())
     {
         entities.EmployeeDatas.Add(value);
         entities.SaveChanges();
         return(value);
     }
 }
        // POST: api/Course
        public CourseTable Post([FromBody] CourseTable value)
        {
            using (database_for_practiceEntities entities = new database_for_practiceEntities())
            {
                value.Instructor = findInstructor(value.InstructorID);
                entities.CourseTables.Attach(value);

                entities.Entry(value).State = System.Data.Entity.EntityState.Unchanged;
                entities.SaveChanges();
                var return_val = entities.CourseTables.Find(value.CourseID);
                return(value);
            }
        }
        public void changePartial(int id, string instructor)
        {
            using (database_for_practiceEntities entities = new database_for_practiceEntities())
            {
                var curEntity = entities.CourseTables.ToList().FirstOrDefault(e => e.CourseID == id);

                if (curEntity != null)
                {
                    curEntity.Instructor = instructor;

                    entities.SaveChanges();
                }
            }
        }
 // DELETE: api/Course/5
 public void Delete(int id)
 {
     using (database_for_practiceEntities entities = new database_for_practiceEntities())
     {
         var toDelete = new CourseTable {
             CourseID = id
         };
         entities.CourseTables.Attach(toDelete);
         if (toDelete != null)
         {
             entities.CourseTables.Remove(toDelete);
             entities.SaveChanges();
         }
     }
 }
        // PUT: api/Course/5
        public CourseTable Put(int id, [FromBody] CourseTable value)
        {
            using (database_for_practiceEntities entities = new database_for_practiceEntities())
            {
                var curEntity = entities.CourseTables.ToList().FirstOrDefault(e => e.CourseID == id);

                if (curEntity != null)
                {
                    curEntity.CourseName     = value.CourseName;
                    curEntity.InstructorID   = value.InstructorID;
                    curEntity.Instructor     = findInstructor(value.InstructorID);
                    curEntity.StudentIdList  = value.StudentIdList;
                    curEntity.Schedule       = value.Schedule;
                    curEntity.LengthOfCourse = value.LengthOfCourse;

                    entities.SaveChanges();
                    return(value);
                }
                return(null);
            }
        }
        // PUT: api/Employee/5
        public EmployeeData Put(int id, [FromBody] EmployeeData value)
        {
            using (database_for_practiceEntities entities = new database_for_practiceEntities())
            {
                var curEntity = entities.EmployeeDatas.ToList().FirstOrDefault(e => e.ID == id);

                var courseEntity = entities.CourseTables.ToList().FirstOrDefault(e => e.InstructorID == id);

                CourseController cc = new CourseController();

                if (curEntity != null)
                {
                    curEntity.FirstName = value.FirstName;
                    curEntity.LastName  = value.LastName;
                    curEntity.Gender    = value.Gender;
                    curEntity.Salary    = value.Salary;
                    cc.changePartial(courseEntity.CourseID, value.FirstName + value.LastName[0]);

                    entities.SaveChanges();
                    return(value);
                }
                return(null);
            }
        }