func (c *WorkItemLinkTypeController) Update(ctx *app.UpdateWorkItemLinkTypeContext) error {
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return errors.NewNotFoundError("spaceID", ctx.ID)
	}
	currentUserIdentityID, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
	}
	// WorkItemLinkTypeController_Update: start_implement
	return application.Transactional(c.db, func(appl application.Application) error {
		toSave := app.WorkItemLinkTypeSingle{
			Data: ctx.Payload.Data,
		}
		if toSave.Data.ID == nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(errors.NewBadParameterError("work item link type", nil))
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		modelLinkTypeToSave, err := ConvertWorkItemLinkTypeToModel(toSave)
		if err != nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(err)
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		modelLinkTypeSaved, err := appl.WorkItemLinkTypes().Save(ctx.Context, *modelLinkTypeToSave)
		if err != nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(err)
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		appLinkType := ConvertWorkItemLinkTypeFromModel(ctx.RequestData, *modelLinkTypeSaved)

		// Enrich
		hrefFunc := func(obj interface{}) string {
			return fmt.Sprintf(app.WorkItemLinkTypeHref(spaceID, "%v"), obj)
		}
		linkTypeCtx := newWorkItemLinkContext(ctx.Context, appl, c.db, ctx.RequestData, ctx.ResponseData, hrefFunc, currentUserIdentityID)
		err = enrichLinkTypeSingle(linkTypeCtx, &appLinkType)
		if err != nil {
			jerrors, _ := jsonapi.ErrorToJSONAPIErrors(goa.ErrInternal("Failed to enrich link type: %s", err.Error()))
			return ctx.InternalServerError(jerrors)
		}
		return ctx.OK(&appLinkType)
	})
	// WorkItemLinkTypeController_Update: end_implement
}
// Update runs the update action.
Update runs the update action.
// Update runs the update action .
func (c *WorkItemLinkTypeController) Update(ctx *app.UpdateWorkItemLinkTypeContext) error {
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return errors.NewNotFoundError("spaceID", ctx.ID)
	}
	currentUserIdentityID, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
	}
	return application.Transactional(c.db, func(appl application.Application) error {
		toSave := app.WorkItemLinkTypeSingle{
			Data: ctx.Payload.Data,
		}
		if toSave.Data.ID == nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(errors.NewBadParameterError("work item link type", nil))
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		modelLinkTypeToSave, err := ConvertWorkItemLinkTypeToModel(toSave)
		if err != nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(err)
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		modelLinkTypeSaved, err := appl.WorkItemLinkTypes().Save(ctx.Context, *modelLinkTypeToSave)
		if err != nil {
			jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(err)
			return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors)
		}
		appLinkType := ConvertWorkItemLinkTypeFromModel(ctx.RequestData, *modelLinkTypeSaved)
		hrefFunc := func(obj interface{}) string {
			return fmt.Sprintf(app.WorkItemLinkTypeHref(spaceID, "%v"), obj)
		}
		linkTypeCtx := newWorkItemLinkContext(ctx.Context, appl, c.db, ctx.RequestData, ctx.ResponseData, hrefFunc, currentUserIdentityID)
		err = enrichLinkTypeSingle(linkTypeCtx, &appLinkType)
		if err != nil {
			jerrors, _ := jsonapi.ErrorToJSONAPIErrors(goa.ErrInternal("Failed to enrich link type: %s", err.Error()))
			return ctx.InternalServerError(jerrors)
		}
		return ctx.OK(&appLinkType)
	})
}
func ( c * WorkItemLinkTypeController ) Update ( ctx * app . UpdateWorkItemLinkTypeContext ) error { spaceID , err := uuid . FromString ( ctx . ID ) if err != nil { return errors . NewNotFoundError ( " " , ctx . ID ) } currentUserIdentityID , err := login . ContextIdentity ( ctx ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewUnauthorizedError ( err . Error ( ) ) ) } return application . Transactional ( c . db , func ( appl application . Application ) error { toSave := app . WorkItemLinkTypeSingle { Data : ctx . Payload . Data , } if toSave . Data . ID == nil { jerrors , httpStatusCode := jsonapi . ErrorToJSONAPIErrors ( errors . NewBadParameterError ( " " , nil ) ) return ctx . ResponseData . Service . Send ( ctx . Context , httpStatusCode , jerrors ) } modelLinkTypeToSave , err := ConvertWorkItemLinkTypeToModel ( toSave ) if err != nil { jerrors , httpStatusCode := jsonapi . ErrorToJSONAPIErrors ( err ) return ctx . ResponseData . Service . Send ( ctx . Context , httpStatusCode , jerrors ) } modelLinkTypeSaved , err := appl . WorkItemLinkTypes ( ) . Save ( ctx . Context , * modelLinkTypeToSave ) if err != nil { jerrors , httpStatusCode := jsonapi . ErrorToJSONAPIErrors ( err ) return ctx . ResponseData . Service . Send ( ctx . Context , httpStatusCode , jerrors ) } appLinkType := ConvertWorkItemLinkTypeFromModel ( ctx . RequestData , * modelLinkTypeSaved ) hrefFunc := func ( obj interface { } ) string { return fmt . Sprintf ( app . WorkItemLinkTypeHref ( spaceID , " " ) , obj ) } linkTypeCtx := newWorkItemLinkContext ( ctx . Context , appl , c . db , ctx . RequestData , ctx . ResponseData , hrefFunc , currentUserIdentityID ) err = enrichLinkTypeSingle ( linkTypeCtx , & appLinkType ) if err != nil { jerrors , _ := jsonapi . ErrorToJSONAPIErrors ( goa . ErrInternal ( " " , err . Error ( ) ) ) return ctx . InternalServerError ( jerrors ) } return ctx . OK ( & appLinkType ) } ) }
Update runs the update action.
Update runs the update action .
// WorkItemLinkTypeController_Update: start_implement // Enrich // WorkItemLinkTypeController_Update: end_implement