list<UserModel> EducationSystemDataModel::getStudentsTakingCoursesTaughtBy(int instructorId)
{
    list<UserModel> students;

    // Iterate over takes entries
    list<TakeModel>::iterator takeItem;
    for(takeItem = takes.begin(); takeItem != takes.end(); takeItem++){
        TakeModel take = *takeItem;

        // 'Take' item for this instructor
        if(take.getInstructorId() == instructorId){

            // Find its matching student
            list<UserModel>::iterator userItem;
            for(userItem = users.begin(); userItem != users.end(); userItem++){
                UserModel user = *userItem;

                if(user.getId() == take.getStudentId()){
                    students.push_back(user);
                }
            }
        }
    }

    return students;
}
bool EducationSystemDataModel::isUserExists(int userId)
{
    list<UserModel>::iterator userItem;
    for(userItem = users.begin(); userItem != users.end(); userItem++){
        UserModel user = *userItem;
        if(user.getId() == userId){
            return true;
        }
    }

    return false;
}
void EducationSystemDataModel::removeInstructor(int id)
{
    // Check for existence
    if(!isUserExists(id)){
        cout << "There's no such user exists" << endl;
        return;
    }

    // Remove this employee
    list<UserModel>::iterator userItem;
    for(userItem = users.begin(); userItem != users.end(); userItem++){
        UserModel user = *userItem;
        if(user.getId() == id){
            users.erase(userItem++);
        }
    }
}
UserModel EducationSystemDataModel::getUserByCredentials(int id, string password, bool &exist)
{
    // Assume we don't have such user
    exist = false;

    // Iterate through users list and check for match
    list<UserModel>::iterator userItem;
    for(userItem = users.begin(); userItem != users.end(); userItem++){
        UserModel user = *userItem;
        if(user.getId() == id && user.getPassword() == password){
            // Match found
            exist = true;
            return user;
        }
    }
    return UserModel();
}