T
TS
From my presentation layer, I call a validation method in my business layer
that i pass a custom class to that holds all parameters. I am currently also
passing an error message by reference so that the calling code can have this
string set to an error message inside this method.
I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the
whole thing as reference?
2. Is there a more elegant approach to handling validation that occurs on
this separate business layer?
thanks a lot!
public bool CanReg(RegValidationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegistered(this.ClassId, this.PartId) == true )
{
errorMessage = AlreadyRegisteredMsg;
return false;
}
}
Funding faFunding= Funding.GetFunding(args.AgentId, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundingSourceMsg;
return false;
}
}
}
that i pass a custom class to that holds all parameters. I am currently also
passing an error message by reference so that the calling code can have this
string set to an error message inside this method.
I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the
whole thing as reference?
2. Is there a more elegant approach to handling validation that occurs on
this separate business layer?
thanks a lot!
public bool CanReg(RegValidationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegistered(this.ClassId, this.PartId) == true )
{
errorMessage = AlreadyRegisteredMsg;
return false;
}
}
Funding faFunding= Funding.GetFunding(args.AgentId, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundingSourceMsg;
return false;
}
}
}