solidarity-transport/handler/availabilities.go

42 lines
1.1 KiB
Go

package handler
import "git.coopgo.io/coopgo-platform/solidarity-transport/types"
func (h *Handler) AddRegularAvailability(driver string, day int, startTime string, endTime string) error {
availability := types.DriverRegularAvailability{
DriverId: driver,
Day: day,
StartTime: startTime,
EndTime: endTime,
}
if err := h.Storage.CreateDriverRegularAvailability(availability); err != nil {
return err
}
return nil
}
func (h *Handler) AddDriverRegularAvailabilities(availabilities []*types.DriverRegularAvailability) error {
if err := h.Storage.CreateDriverRegularAvailabilities(availabilities); err != nil {
return err
}
return nil
}
func (h *Handler) GetDriverRegularAvailabilities(driver string) ([]*types.DriverRegularAvailability, error) {
availabilities, err := h.Storage.GetDriverRegularAvailabilities(driver)
if err != nil {
return nil, err
}
return availabilities, nil
}
func (h *Handler) DeleteDriverRegularAvailabilities(driver string, availability string) error {
if err := h.Storage.DeleteDriverRegularAvailability(driver, availability); err != nil {
return err
}
return nil
}