Question

I have an MVC2 application with the following classes:

-OrderModel

-LineOrderModel

-OrderController

-LineOrderController

In the OrderController class I'm recollecting some values of a web form . Until now, I created instances of each order line (LineOrderModel class) and OrderClass inside of the Controller.

I was trying to create a OrderFacade class in order to encapsulate the different things to do when creating an order.

So in that class I created a method like this:

public void saveOrder(int idProvider,decimal? price)
        {
            // Here I create instances of OrderModel and LineOrderModel
            // and assign their properties
        }

but my problem is I don't know how to pass all the order lines captured from the web form.

I think it doesn't make sense to create and pass to that method a List with orderLines class (because the point of this is to operate with the Facade, not with the class directly)

How could I encapsulate the different lines (all with properties like numberUnits,idProduct ...) into a List of generic objects, each one with these properties?

Maybe something like a List<List<object>> ?

Thanks in advance!

Was it helpful?

Solution

Sounds like you don't need facade. Facade would be good choice if you use data transfer objects (DTOs) between your business logic and application logic (controllers) - in such scenario DTOs can also be view models (I guess orthodox MVC developers will don't like this idea). Facade would take DTOs and convert them into some business or domain objects.

But in your scenario you simply need to fill data directly to your model classes - that is purpose of view model classes to use them in views and controllers. Using any kind of property bags to transfer data from controller to business logic is not a nice solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top