/*
DESCRIPTION:
Any functions that are used internally by the use-case
*/
package vehiclehist

import (
	"encoding/json"
	vh "simrs-vx/internal/domain/main-entities/vehicle-hist"
	"time"
)

func setData(input vh.CreateDto, data *vh.VehicleHist) {
	now := time.Now()
	data.Vehicle_Id = &input.Vehicle.Id
	data.Date = &now
	data.Data = toStringPtr(input.Vehicle)
	data.Crud_Code = &input.Crud_Code
}

func toStringPtr(v any) *string {
	b, _ := json.Marshal(v)
	s := string(b)
	return &s
}
