func (r *GormWorkItemLinkRepository) Save(ctx context.Context, linkToSave WorkItemLink, modifierID uuid.UUID) (*WorkItemLink, error) {
	logrus.Info(fmt.Sprintf("saving workitem link with type =  %s", linkToSave.LinkTypeID))
	existingLink := WorkItemLink{}
	db := r.db.Model(&existingLink).Where("id=?", linkToSave.ID).First(&existingLink)
	if db.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
		}, "work item link not found")
		return nil, errors.NewNotFoundError("work item link", linkToSave.ID.String())
	}
	if db.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
			"err":    db.Error,
		}, "unable to find work item link")
		return nil, errors.NewInternalError(db.Error.Error())
	}
	if existingLink.Version != linkToSave.Version {
		return nil, errors.NewVersionConflictError("version conflict")
	}
	linkToSave.Version = linkToSave.Version + 1
	if err := r.ValidateCorrectSourceAndTargetType(ctx, existingLink.SourceID, existingLink.TargetID, existingLink.LinkTypeID); err != nil {
		return nil, errs.WithStack(err)
	}
	// save
	db = r.db.Save(&linkToSave)
	if db.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
			"err":    db.Error,
		}, "unable to save work item link")
		return nil, errors.NewInternalError(db.Error.Error())
	}
	// save a revision of the modified work item link
	if err := r.revisionRepo.Create(ctx, modifierID, RevisionTypeUpdate, linkToSave); err != nil {
		return nil, errs.Wrapf(err, "error while saving work item")
	}
	log.Info(ctx, map[string]interface{}{
		"wil_id": linkToSave.ID,
	}, "Work item link updated")
	return &linkToSave, nil
}
// Save updates the given work item link in storage. Version must be the same as the one int the stored version.
// returns NotFoundError, VersionConflictError, ConversionError or InternalError
Save updates the given work item link in storage. Version must be the same as the one int the stored version.
returns NotFoundError, VersionConflictError, ConversionError or InternalError
// Save updates the given work item link in storage . Version must be the same as the one int the stored version . // returns NotFoundError VersionConflictError ConversionError or InternalError
func (r *GormWorkItemLinkRepository) Save(ctx context.Context, linkToSave WorkItemLink, modifierID uuid.UUID) (*WorkItemLink, error) {
	logrus.Info(fmt.Sprintf("saving workitem link with type =  %s", linkToSave.LinkTypeID))
	existingLink := WorkItemLink{}
	db := r.db.Model(&existingLink).Where("id=?", linkToSave.ID).First(&existingLink)
	if db.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
		}, "work item link not found")
		return nil, errors.NewNotFoundError("work item link", linkToSave.ID.String())
	}
	if db.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
			"err":    db.Error,
		}, "unable to find work item link")
		return nil, errors.NewInternalError(db.Error.Error())
	}
	if existingLink.Version != linkToSave.Version {
		return nil, errors.NewVersionConflictError("version conflict")
	}
	linkToSave.Version = linkToSave.Version + 1
	if err := r.ValidateCorrectSourceAndTargetType(ctx, existingLink.SourceID, existingLink.TargetID, existingLink.LinkTypeID); err != nil {
		return nil, errs.WithStack(err)
	}
	db = r.db.Save(&linkToSave)
	if db.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"wil_id": linkToSave.ID,
			"err":    db.Error,
		}, "unable to save work item link")
		return nil, errors.NewInternalError(db.Error.Error())
	}
	 a revision of the modified work item link
	if err := r.revisionRepo.Create(ctx, modifierID, RevisionTypeUpdate, linkToSave); err != nil {
		return nil, errs.Wrapf(err, "error while saving work item")
	}
	log.Info(ctx, map[string]interface{}{
		"wil_id": linkToSave.ID,
	}, "Work item link updated")
	return &linkToSave, nil
}
func ( r * GormWorkItemLinkRepository ) Save ( ctx context . Context , linkToSave WorkItemLink , modifierID uuid . UUID ) ( * WorkItemLink , error ) { logrus . Info ( fmt . Sprintf ( " " , linkToSave . LinkTypeID ) ) existingLink := WorkItemLink { } db := r . db . Model ( & existingLink ) . Where ( " " , linkToSave . ID ) . First ( & existingLink ) if db . RecordNotFound ( ) { log . Error ( ctx , map [ string ] interface { } { " " : linkToSave . ID , } , " " ) return nil , errors . NewNotFoundError ( " " , linkToSave . ID . String ( ) ) } if db . Error != nil { log . Error ( ctx , map [ string ] interface { } { " " : linkToSave . ID , " " : db . Error , } , " " ) return nil , errors . NewInternalError ( db . Error . Error ( ) ) } if existingLink . Version != linkToSave . Version { return nil , errors . NewVersionConflictError ( " " ) } linkToSave . Version = linkToSave . Version + 1 if err := r . ValidateCorrectSourceAndTargetType ( ctx , existingLink . SourceID , existingLink . TargetID , existingLink . LinkTypeID ) ; err != nil { return nil , errs . WithStack ( err ) } db = r . db . Save ( & linkToSave ) if db . Error != nil { log . Error ( ctx , map [ string ] interface { } { " " : linkToSave . ID , " " : db . Error , } , " " ) return nil , errors . NewInternalError ( db . Error . Error ( ) ) } if err := r . revisionRepo . Create ( ctx , modifierID , RevisionTypeUpdate , linkToSave ) ; err != nil { return nil , errs . Wrapf ( err , " " ) } log . Info ( ctx , map [ string ] interface { } { " " : linkToSave . ID , } , " " ) return & linkToSave , nil }
Save updates the given work item link in storage.
Save updates the given work item link in storage .
// save // save a revision of the modified work item link