package seeds

import (
	"gorm.io/gorm"
	"web-qudo-be/app/database/entity"
)

type MasterStatusesSeeder struct{}

var masterStatuses = []entity.MasterStatuses{
	{
		ID:       1,
		Name:     "Waiting",
		IsActive: true,
	},
	{
		ID:       2,
		Name:     "Active",
		IsActive: true,
	},
	{
		ID:       3,
		Name:     "Inactive",
		IsActive: true,
	},
}

func (MasterStatusesSeeder) Seed(conn *gorm.DB) error {
	for _, row := range masterStatuses {
		if err := conn.Create(&row).Error; err != nil {
			return err
		}
	}

	return nil
}

func (MasterStatusesSeeder) Count(conn *gorm.DB) (int, error) {
	var count int64
	if err := conn.Model(&entity.MasterStatuses{}).Count(&count).Error; err != nil {
		return 0, err
	}

	return int(count), nil
}
