package entitymapping import ( "bitbucket.org/nemt/nemt-portal-api/application/viewmodel" "bitbucket.org/nemt/nemt-portal-api/domain/entity" ) // providerMapping has method to map provider entities to view models type profileMapping struct { mapper *Mapper } // ToUserEntitySlice maps a User entity slice to User view model slice func (mapping *profileMapping) ToProfileEntitySlice(list []viewmodel.Profile) (retVal []entity.Profile) { retVal = make([]entity.Profile, 0) for _, item := range list { retVal = append(retVal, mapping.ToProfileEntity(item)) } return retVal } func (mapping *profileMapping) ToProfileEntity(model viewmodel.Profile) entity.Profile { return entity.Profile{ ID: model.ID, Key: model.Key, Name: model.Name, Description: model.Description, Created: model.Created, Updated: model.Updated, Active: model.Active, Visible: model.Visible, Blocked: model.Blocked, Suspended: model.Suspended, Organization: mapping.mapper.Organization.ToOrganizationEntity(model.Organization), } } // ToUserEntitySlice maps a User entity slice to User view model slice func (mapping *profileMapping) ToProfileModelSlice(list []entity.Profile) (retVal []viewmodel.Profile) { retVal = make([]viewmodel.Profile, 0) for _, item := range list { retVal = append(retVal, mapping.ToProfileModel(item)) } return retVal } func (mapping *profileMapping) ToProfileModel(model entity.Profile) viewmodel.Profile { return viewmodel.Profile{ ID: model.ID, Key: model.Key, Name: model.Name, Description: model.Description, Created: model.Created, Updated: model.Updated, Active: model.Active, Visible: model.Visible, Blocked: model.Blocked, Suspended: model.Suspended, Organization: mapping.mapper.Organization.ToOrganizationModel(model.Organization), } }