>>>Could you reformat it into a switch statement?
>>>
>>>Bill
>>>
>>
>>How about this case - is there a way to simplify? (In VFP it's case expression):
>>
>>
>> Boolean isRedemptionValid = row.Field<Boolean>("IsRedemptionValid"),
>> isDateValid = row.Field<Boolean>("IsDateValid"),
>> isTimeValid = row.Field<Boolean>("IsTimeValid"),
>> isDowValid = row.Field<Boolean>("IsDowValid");
>>
>> if (isRedemptionValid && isDateValid && isTimeValid && isDowValid)
>> {
>> availability = "Available for Redemption";
>> }
>> else
>> if (!isRedemptionValid)
>> {
>> availability = "Not enough number of uses";
>> }
>> else
>> if (!isDateValid)
>> {
>> availability = "Not available in the date range";
>> }
>> else
>> if (!isTimeValid)
>> {
>> availability = "Not available in the time range";
>> }
>> else
>> {
>> availability = "Not available on that day of the week";
>> }
>
>Questions : Do you really want to abort the checks after the first 'fail' ?
>If 'yes' then I'd put it in a separate method with multiple returns (although I know there are those who religiously insist on one exit point :-})
>If 'no' then something based on Bill's approach (but with a string builder)
I think I want to return just the main reason. I've been thinking that I probably should just return this info as a column using case in T-SQL. Since this information is coming from a stored procedure, I see no problem adding an extra column right away.
I'll probably go with that route, Craig's suggestion made me think about it yesterday.
If it's not broken, fix it until it is.
My Blog