Пример #1
0
func (maker *AssignmentMaker) CreateAssignment(assig *Assignment) error {
	query, _, err := sq.
		Insert("assignment").Columns("student_id", "teacher_id").
		Values(assig.StudentID, assig.TeacherID).
		ToSql()
	if err != nil {
		return err
	}

	result, err := util.PrepAndExec(query, maker, assig.StudentID, assig.TeacherID)
	if err != nil {
		return err
	}

	id, err := result.LastInsertId()
	if err != nil {
		return err
	}
	assig.ID = id

	return nil
}
Пример #2
0
func (maker *teacherMaker) Create(teacher *Teacher) error {
	UserStore.Create(&teacher.User)

	query, _, err := sq.
		Insert("teacher").Columns("user_id").Values("user_id").
		ToSql()
	if err != nil {
		return err
	}

	result, err := util.PrepAndExec(query, maker, teacher.User.ID)
	if err != nil {
		return err
	}

	id, err := result.LastInsertId()
	if err != nil {
		return err
	}
	teacher.ID = id

	return nil
}