1
0
Fork 0
This commit is contained in:
Vojtěch Mareš 2024-05-04 18:21:37 +02:00
parent 7ed1e05284
commit 49e05cac10
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
23 changed files with 613 additions and 253 deletions

View file

@ -77,6 +77,7 @@ func (r *AttendeeRepository) CountForDate(dateID training.DateID) (int, error) {
}
func (r *AttendeeRepository) Create(a *training.Attendee) error {
a.ID = training.NewAttendeeID()
_, err := r.db.Exec("INSERT INTO attendee (id, date_id, name, email, company, role, is_student, has_attended, has_paid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", a.ID, a.DateID, a.Name, a.Email, a.Company, a.Role, a.IsStudent, a.HasAttended, a.HasPaid)
return err
}

View file

@ -69,6 +69,7 @@ func (r *DateRepository) FindAllForTraining(id training.ID) ([]training.Date, er
}
func (r *DateRepository) Create(d *training.Date) error {
d.ID = training.NewDateID()
_, err := r.db.Exec("INSERT INTO date (id, date, training_id, start_time, days, price, is_online, location, address, capacity) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", d.ID, d.Date, d.TrainingID, d.StartTime, d.Days, d.Price, d.IsOnline, d.Location, d.Address, d.Capacity)
return err
}

View file

@ -15,6 +15,7 @@ func NewTrainingRepository(db *sql.DB) *TrainingRepository {
}
func (r *TrainingRepository) Create(t *training.Training) error {
t.ID = training.NewID()
_, err := r.db.Exec("INSERT INTO training (id, name, days, description, price) VALUES ($1, $2, $3)", t.ID, t.Name, t.Days, t.Description, t.Price)
return err
}