package cn.hmsoft.ltc.service.impl;

import java.sql.SQLException;
import java.util.List;
import cn.hmsoft.ltc.dao.SubjectOptionDao;
import cn.hmsoft.ltc.model.SubjectOption;
import cn.hmsoft.ltc.service.iface.SubjectOptionServie;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

public class SubjectOptionServieImpl implements SubjectOptionServie {

	private SubjectOptionDao subjectOptionDao = new SubjectOptionDao();

	public List<SubjectOption> findSubjectOptions(Integer subjectId) throws SQLException {
		return this.subjectOptionDao.findSubjectOptions(subjectId);
	}

	@Override
	public void insertSubjectOption(Integer subjectId, ObservableList<SubjectOption> subjectOptionList) {
		this.subjectOptionDao.insertSubjectOption(subjectId, subjectOptionList);
	}
	
	public ObservableList<SubjectOption> findSubjectOptionLists(Integer subjectId) throws SQLException {
		ObservableList<SubjectOption> list = FXCollections.observableArrayList();
		List<SubjectOption> subs = this.subjectOptionDao.findSubjectOptions(subjectId);
		for (SubjectOption subjectOption : subs) {
			list.add(subjectOption);
		}
		return list;
	}

	@Override
	public void deleteSubjectOption(SubjectOption subjectOption) throws SQLException {
		subjectOptionDao.deleteSubjectOption(subjectOption);
	}
}
