Aval
Aval

Reputation: 1

What should be the responsibility of a presenter here?

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

Upvotes: 0

Views: 55

Answers (1)

Matthew Manela
Matthew Manela

Reputation: 16752

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.

Upvotes: 1

Related Questions