This project has moved and is read-only. For the latest updates, please go here.

Brands and Products

Again, the use case is:
  • A brand can have several products.
  • For each brand, the product name must be unique but the product name can be repeated on other brands. (1)
  • The product code must be unique regardless of its brand. (2)
  • Each product must have a unit price that will be used at invoice time.
  • Brands and product entry should be simple and fast. Our customer mentioned a grid would be a good solution.
  • A search form for products will be needed for two uses:
    • product updates (mainly price)
    • as part of invoice entry

Customers and Customer Types

Again the use case is:
  • Customers exist only to be invoiced. They have no address (this is a small island and it's easy to find people).
  • The single attribute of customers is the customer type.
  • Customer and customer type entry should be simple and fast. Again they mentioned grids as a good solution.
  • A customer search form must exist for two uses:
    • as part of invoice entry
    • keeping track of customer's invoices
Our customer wants a grid and Csla Dynamic stereotypes provides the behaviour we need for an auto saving data grid. So Brands will be a DynamicEditableRootCollection made of items Brand DynamicEditableRoot objects. As for Products it sure is an EditableChildCollection made of items Product EditableChild objects. For the present use case, there isn't much to say about product unit price. More details are discussed under Invoices and invoice items.

Business rules:
(1) This is an easy rule: take the Products parent collection and for every Product item, check its name doesn't match any the current product name.
(2) This is harder: take the Brands grand-parent collection and for each Brand item, for every Product item, check its code doesn't match any the current product code.
These rules won't be generated. Their inclusion in the project illustrate how you can use hand coded rules with CslaGenFork generated code.

Defining business objects

1 - Open the tables folder
2 - Click on Brands table
3 - Right click and select Create Dynamic Root Collection

BrandColl DynamicRootCollection
You will be asked for collection and item names.
4 - For the Collection Name type BrandColl
5 - For the Item Name type Brand
6 - Press OK and notice there are two new objects in the Csla Objects panel. Let's check some object details on Csla Object Info:
  • Click BrandColl and check
    • 01. Common Options - Csla Object Type shows DynamicEditableRootCollection
    • 05. Collection Options - Item Type shows Brand
  • Click Brand and check
    • 01. Common Options - Csla Object Type shows DynamicEditableRoot
    • 02. Business Properties - open Value Properties property grid to see the object properties; they match the columns of the Brands table
    • 04. Child Object Options - Parent Type shows BrandColl
7 - Repeat for CustomerType and Customer

Last edited Sep 22, 2011 at 4:26 PM by RumbleCow, version 36


RumbleCow Sep 14, 2011 at 12:50 AM 
Step 3 Options are different
Step 6. Three objects were creared BrandCol (2x) and Brand