package grpc

import (
	pb "htwkalender/common/genproto/modules"
	"htwkalender/data-manager/model"
)

func eventToProto(event *model.Event) *pb.Event {
	return &pb.Event{
		Uuid:       event.UUID,
		Day:        event.Day,
		Week:       event.Week,
		Start:      event.Start.String(),
		End:        event.End.String(),
		Name:       event.Name,
		EventType:  event.EventType,
		Compulsory: event.Compulsory,
		Prof:       event.Prof,
		Rooms:      event.Rooms,
		Notes:      event.Notes,
		BookedAt:   event.BookedAt,
		Course:     event.Course,
		Semester:   event.Semester,
	}
}

func eventsToProto(events model.Events) []*pb.Event {
	protoEvents := make([]*pb.Event, 0)
	for _, event := range events {
		protoEvents = append(protoEvents, eventToProto(&event))
	}
	return protoEvents
}

func feedToProto(feed *model.Feed) *pb.Feed {
	return &pb.Feed{
		Id:        feed.Id,
		Created:   feed.Created.String(),
		Updated:   feed.Updated.String(),
		Retrieved: feed.Retrieved.String(),
		Modules:   feed.Modules,
	}
}
