<cfcomponent
extends="BaseFacade"
output="false"
hint="I provide value-based methods for Photo Gallery functionality.">
<cffunction
name="Init"
access="public"
returntype="any"
output="false"
hint="I return an initialized object.">
<cfreturn THIS />
</cffunction>
<cffunction
name="DeletePhotoGallery"
access="public"
returntype="any"
output="false"
hint="I delete the photo gallery with the given ID. If the ID is invalid, I throw an exception.">
<cfargument
name="ID"
type="numeric"
required="true"
hint="I am the ID of the photo gallery to delete."
/>
<cfset var LOCAL = {} />
<cfset LOCAL.PhotoGallery = VARIABLES.PhotoGalleryService
.Load( ARGUMENTS.ID )
/>
<cfreturn LOCAL.PhotoGallery.DeleteWithTransaction() />
</cffunction>
<cffunction
name="GetPhotoGalleriesByKeyword"
access="public"
returntype="array"
output="false"
hint="I return an array of photo galleries that match the given keywords.">
<cfargument
name="Keywords"
type="string"
required="true"
hint="I am the keywords on which we are searching."
/>
<cfreturn VARIABLES.PhotoGalleryService
.GetGalleriesByKeyword( ARGUMENTS.Keywords )
/>
</cffunction>
<cffunction
name="GetPhotoGallery"
access="public"
returntype="any"
output="false"
hint="I load the photo gallery with the given ID. If the ID is invalid, I throw an exception, unless flagged to return an empty gallery object.">
<cfargument
name="ID"
type="numeric"
required="true"
hint="I am the ID of the photo gallery to load."
/>
<cfargument
name="ReturnNewIfInvalid"
type="boolean"
required="false"
default="false"
hint="I am a boolean that flags the desire to return a New() photo gallery rather than raising an excpetion if the given ID is invalid."
/>
<cfset var LOCAL = {} />
<cftry>
<cfset LOCAL.PhotoGallery = VARIABLES.PhotoGalleryService
.Load( ARGUMENTS.ID )
/>
<cfcatch>
<cfif ARGUMENTS.ReturnNewIfInvalid>
<cfset LOCAL.PhotoGallery =
VARIABLES.PhotoGalleryService.New() />
<cfelse>
<cfrethrow />
</cfif>
</cfcatch>
</cftry>
<cfreturn LOCAL.PhotoGallery />
</cffunction>
<cffunction
name="GetPhotoGalleryByJumpCode"
access="public"
returntype="any"
output="false"
hint="I return the photo gallery with the given jump code. If the jump code is invalid, I throw an exception.">
<cfargument
name="JumpCode"
type="string"
required="true"
hint="I am the jump code on which we are searching."
/>
<cfreturn VARIABLES.PhotoGalleryService
.GetGalleryByJumpCode( ARGUMENTS.JumpCode )
/>
</cffunction>
<cffunction
name="SavePhotoGallery"
access="public"
returntype="struct"
output="false"
hint="I save a photo galery based on the given properties.">
<cfargument
name="ID"
type="numeric"
required="false"
default="0"
hint="I am the ID of the photo."
/>
<cfargument
name="Name"
type="string"
required="false"
default=""
hint="I am the name of the gallery."
/>
<cfargument
name="Description"
type="string"
required="false"
default=""
hint="I am the description of the gallery."
/>
<cfargument
name="PhotoIDList"
type="string"
required="false"
default=""
hint="I am the list of photo IDs associated with this gallery."
/>
<cfset var LOCAL = {} />
<cfset LOCAL.PhotoGallery = THIS.GetPhotoGallery(
ARGUMENTS.ID,
true
) />
<cfset LOCAL.PhotoGallery
.SetName( ARGUMENTS.Name )
.SetDescription( ARGUMENTS.Description )
.SetPhotos(
VARIABLES.PhotoService.GetPhotosByIDList(
ARGUMENTS.PhotoIDList
)
)
/>
<cfset LOCAL.Return = {
Success = true,
Errors = LOCAL.PhotoGallery.Validate(),
PhotoGallery = LOCAL.PhotoGallery
} />
<cfif StructCount( LOCAL.Return.Errors )>
<cfset LOCAL.Return.Success = false />
<cfelse>
<cfset LOCAL.PhotoGallery.SaveWithTransaction() />
</cfif>
<cfreturn LOCAL.Return />
</cffunction>
</cfcomponent>