What should be the responsibility of a presenter here?

Posted by Achu on Stack Overflow See other posts from Stack Overflow or by Achu
Published on 2010-04-05T03:38:29Z Indexed on 2010/04/05 3:43 UTC
Read the original article Hit count: 504

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

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about design-patterns