Duwamish7 study notes (four)

xiaoxiao2021-03-06  41

BusinessRules project

1.customer class

Long-term knowledge! In "Duwamish7 study notes (3), what is also written in the business logic layer.

Check or check! Each line, each column, including type and length, think about the verification of the project, really a little sweat!

/ / -------------------------------------------------------------------------------------------- ----------------

// Function Validate:

// Validates and Customer

// Returns:

// True if Validation Is Successful

// false if invalid fields exist

// Parameters:

// [in] Customerrow: CustomerData to Be Validated

// [OUT] Customerrow: Returns Customer Data. If Theree Fields

// That Contain Errors They Are Individually Marked.

/ / -------------------------------------------------------------------------------------------- ----------------

Private Bool Validate (DataRow Customerrow)

{

Bool isvalid;

Customerrow.clearerrrs ();

Isvalid = isvalidemail (customerrow);

Isvalid & = isvalidfield (Customerrow, CustomerData.Name_Field, 40);

Isvalid & = isvalidfield (Customerrow, CustomerData.Address_field, 255);

Isvalid & = isvalidfield (Customerrow, CustomerData.country_field, 40);

Isvalid & = isvalidfield (Customerrow, CustomerData.Phone_field, 30);

IF (! isvalid)

{

Customerrow.RowError = CustomerData.INValid_fields;

}

Return isvalid;

}

All checks are called after passing, and the operational access layer will be called to operate, with use, so that the created Customers can be released immediately.

Using (Customers CustomersAccess = New Customers ())

{

Result = CustomersAccess.UpdateCustomer (CUSTOMER);

}

The following records a little knowledge

Set line error: Row.RowError

Set column error: row.setColumNError ()

Clear error: row.clearerrors ()

Regular expression of mail verification: regexp_isvalidemail = @ "^ / w ((- / w ) | (/.)) * / @ / W ((/.

2.Order class

After reading the ORDER class, this layer is very good. This layer is the real business such as CalculaTax (), CalculateShipping (), InsertOrder (). Business logic layer When the service method is packaged, it makes a very stringent check. Make the system a very strong robustness. Sighing! Question: Duwamish is just a small example of MS, there is a lot of objects in the actual big project, very and more complex business logic, can our code you can write?

转载请注明原文地址:https://www.9cbs.com/read-78381.html

New Post(0)