0

I am using 3-Tier layer for my ASP.net project. i have a table in Database “PaymentTypes” where i put check constraint on the column PaymentTypeEN, so the user will not enter the duplicate values in this column. I have code in my Domain Layer (VB.net).

_

Public Function PaymentTypes_DML(ByVal PaymentTypeID As Long?, ByVal PaymentTypeEN As String, ByVal PaymentType As String, _
ByVal UserID As Long?, ByVal ActionCode As String) As Long
Dim iPaymentTypeID As Long? = PaymentTypeID
Dim sPaymentTypeEN As String = PaymentTypeEN
Dim sPaymentType As String = PaymentType
Dim iUserID As Long? = UserID
Dim sActionCode As String = ActionCode
Dim result As Long
result = CLng(PaymentTypesAdapter.DML(iPaymentTypeID, sPaymentTypeEN, sPaymentType, iUserID, sActionCode))
Return result
End Function

No what is happening when on the Presentation layer (ASP.net Form) when user enter the duplicate record in the Column “PaymentTypeEN” the ASP.net page shows ugly error…………i want to handle those errors by showing the user some pre defined messages in this case….like……”You can’t enter duplicate values, please enter some other value.”………………….How can i handle the Errors in Domain Layer or in Presentation layer for ObjectDataSource.

Usman Jalil
  • 121
  • 4
  • 10

1 Answers1

0

Validation is something that often has to be duplicated at multiple layers. There is a large advantage in putting it primarily in the business layer. This allows the validation in the ui to use business logic for it's validation independently of the DAO layer.

This does mean your check constraint is probably irrelevant, as you will have to duplicate it's functionality in the business layer anyway.

You will probably have to create a validate() method which calls the data layer, doing a search for other records with the relevant PaymentTypeEN.

Rob Conklin
  • 8,806
  • 1
  • 19
  • 23