package internal

type Repositories struct {
	registrationRepo RegistrationRepository
	outboxRepo       OutboxRepository
}

type RegistrationRepository interface {
	Update() error
}
type OutboxRepository interface {
	InformAbout() error
}

type RegistrationService struct {
	txProvider TransactionProvider
}

func NewRegistrationService(txProvider TransactionProvider) *RegistrationService {
	return &RegistrationService{txProvider: txProvider}
}

func (rs *RegistrationService) RegisterNewAttendee() error {

	return rs.txProvider.Transact(func(repos Repositories) error {
		err := repos.registrationRepo.Update()
		if err != nil {
			return err
		}
		return repos.outboxRepo.InformAbout()
	})

}
