func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, name string, description *string, sourceTypeID, targetTypeID uuid.UUID, forwardName, reverseName, topology string, linkCategoryID, spaceID uuid.UUID) (*WorkItemLinkType, error) {
	linkType := &WorkItemLinkType{
		Name:           name,
		Description:    description,
		SourceTypeID:   sourceTypeID,
		TargetTypeID:   targetTypeID,
		ForwardName:    forwardName,
		ReverseName:    reverseName,
		Topology:       topology,
		LinkCategoryID: linkCategoryID,
		SpaceID:        spaceID,
	}
	if err := linkType.CheckValidForCreation(); err != nil {
		return nil, errs.WithStack(err)
	}

	// Check link category exists
	linkCategory := WorkItemLinkCategory{}
	db := r.db.Where("id=?", linkType.LinkCategoryID).Find(&linkCategory)
	if db.RecordNotFound() {
		return nil, errors.NewBadParameterError("work item link category", linkType.LinkCategoryID)
	}
	if db.Error != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("Failed to find work item link category: %s", db.Error.Error()))
	}
	// Check space exists
	space := space.Space{}
	db = r.db.Where("id=?", linkType.SpaceID).Find(&space)
	if db.RecordNotFound() {
		return nil, errors.NewBadParameterError("work item link space", linkType.SpaceID)
	}
	if db.Error != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("Failed to find work item link space: %s", db.Error.Error()))
	}

	db = r.db.Create(linkType)
	if db.Error != nil {
		return nil, errors.NewInternalError(db.Error.Error())
	}
	return linkType, nil
}
// Create creates a new work item link type in the repository.
// Returns BadParameterError, ConversionError or InternalError
Create creates a new work item link type in the repository.
Returns BadParameterError, ConversionError or InternalError
// Create creates a new work item link type in the repository . // Returns BadParameterError ConversionError or InternalError
func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, name string, description *string, sourceTypeID, targetTypeID uuid.UUID, forwardName, reverseName, topology string, linkCategoryID, spaceID uuid.UUID) (*WorkItemLinkType, error) {
	linkType := &WorkItemLinkType{
		Name:           name,
		Description:    description,
		SourceTypeID:   sourceTypeID,
		TargetTypeID:   targetTypeID,
		ForwardName:    forwardName,
		ReverseName:    reverseName,
		Topology:       topology,
		LinkCategoryID: linkCategoryID,
		SpaceID:        spaceID,
	}
	if err := linkType.CheckValidForCreation(); err != nil {
		return nil, errs.WithStack(err)
	}
	linkCategory := WorkItemLinkCategory{}
	db := r.db.Where("id=?", linkType.LinkCategoryID).Find(&linkCategory)
	if db.RecordNotFound() {
		return nil, errors.NewBadParameterError("work item link category", linkType.LinkCategoryID)
	}
	if db.Error != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("Failed to find work item link category: %s", db.Error.Error()))
	}
	space := space.Space{}
	db = r.db.Where("id=?", linkType.SpaceID).Find(&space)
	if db.RecordNotFound() {
		return nil, errors.NewBadParameterError("work item link space", linkType.SpaceID)
	}
	if db.Error != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("Failed to find work item link space: %s", db.Error.Error()))
	}
	db = r.db.Create(linkType)
	if db.Error != nil {
		return nil, errors.NewInternalError(db.Error.Error())
	}
	return linkType, nil
}
func ( r * GormWorkItemLinkTypeRepository ) Create ( ctx context . Context , name string , description * string , sourceTypeID , targetTypeID uuid . UUID , forwardName , reverseName , topology string , linkCategoryID , spaceID uuid . UUID ) ( * WorkItemLinkType , error ) { linkType := & WorkItemLinkType { Name : name , Description : description , SourceTypeID : sourceTypeID , TargetTypeID : targetTypeID , ForwardName : forwardName , ReverseName : reverseName , Topology : topology , LinkCategoryID : linkCategoryID , SpaceID : spaceID , } if err := linkType . CheckValidForCreation ( ) ; err != nil { return nil , errs . WithStack ( err ) } linkCategory := WorkItemLinkCategory { } db := r . db . Where ( " " , linkType . LinkCategoryID ) . Find ( & linkCategory ) if db . RecordNotFound ( ) { return nil , errors . NewBadParameterError ( " " , linkType . LinkCategoryID ) } if db . Error != nil { return nil , errors . NewInternalError ( fmt . Sprintf ( " " , db . Error . Error ( ) ) ) } space := space . Space { } db = r . db . Where ( " " , linkType . SpaceID ) . Find ( & space ) if db . RecordNotFound ( ) { return nil , errors . NewBadParameterError ( " " , linkType . SpaceID ) } if db . Error != nil { return nil , errors . NewInternalError ( fmt . Sprintf ( " " , db . Error . Error ( ) ) ) } db = r . db . Create ( linkType ) if db . Error != nil { return nil , errors . NewInternalError ( db . Error . Error ( ) ) } return linkType , nil }
Create creates a new work item link type in the repository.
Create creates a new work item link type in the repository .
// Check link category exists // Check space exists