package entitymapping

import (
	"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
	"bitbucket.org/nemt/nemt-portal-api/domain/entity"
)

// zipcodeMapping has method to map zipcode entities to view models
type zipcodeMapping struct {
	mapper *Mapper
}

// ToUserEntitySlice maps a User entity slice to User view model slice
func (mapping *zipcodeMapping) ToZipcodeEntitySlice(list []viewmodel.Zipcode) (retVal []entity.Zipcode) {
	retVal = make([]entity.Zipcode, 0)

	for _, item := range list {
		retVal = append(retVal, mapping.ToZipcodeEntity(item))
	}

	return retVal
}

func (mapping *zipcodeMapping) ToZipcodeEntity(model viewmodel.Zipcode) entity.Zipcode {
	return entity.Zipcode{
		ID:           	model.ID,
		UUID:          	model.UUID,
		Zipcode:        model.Zipcode,
		Participating:  model.Participating,
	}
}

// ToUserEntitySlice maps a User entity slice to User view model slice
func (mapping *zipcodeMapping) ToZipcodeModelSlice(list []entity.Zipcode) (retVal []viewmodel.Zipcode) {
	retVal = make([]viewmodel.Zipcode, 0)

	for _, item := range list {
		retVal = append(retVal, mapping.ToZipcodeModel(item))
	}

	return retVal
}

func (mapping *zipcodeMapping) ToZipcodeModel(model entity.Zipcode) viewmodel.Zipcode {
	return viewmodel.Zipcode{
		ID:           	model.ID,
		UUID:          	model.UUID,
		Zipcode:        model.Zipcode,
		Participating:  model.Participating,
	}
}
