views:

18

answers:

1

I have a 3 layer design. (UI / BLL / DAL)

UI = ASP.NET MVC

In my view I have collection of products for a category. Example: Product 1, Product 2 etc..

A user able to select or remove (by selecting check box) product’s from the view, finally save as a collection when user submit these changes.

With this 3 layer design how this product collection will be saved? How the filtering of products (removal and addition) to the category object?

Here are my options.

(A) It is the responsibility of the controller then the pseudo Code would be

  1. Find products that the user selected or removed and compare with existing records.
  2. Add or delete that collection to category object.
  3. Call SaveCategory(category); // BLL CALL

Here the first 2 process steps occurs in the controller.

(B) It is the responsibility of BLL then pseudo Code would be

  1. Collect products what ever user selected
  2. SaveCategory(category, products); // BLL CALL

Here it's up to the SaveCategory (BLL) to decide what products should be removed and added to the database.

Thanks

+1  A: 

The logic should live in the business layer and not the controller. Your controller should be as thin as possible and just orchestrate communication between the view and the other layers that deal with your models and business requirements.

Matthew Manela
So it means I need to use DTO to transfer user collection to BLL. Right? I am trying to avoid DTO and use the entity straight from the controller. Basically user can add or remove anything from presenter, but in BLL it will be validated.
Aval