質問

次のクラスを持つMVC2アプリケーションがあります。

--OrderModel

lineOrderModel

-OrderController

-lineOrderController

OrderControllerクラスでは、Webフォームのいくつかの値を思い出しています。これまで、コントローラ内の各注文行(LineOrdeModelクラス)とOrderClassのインスタンスを作成しました。

注文を作成するときにさまざまなことをカプセル化するためにOrderFacadeクラスを作成しようとしていました。

SOのクラスでは、このようなメソッドを作成しました。

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

しかし私の問題は私はWebフォームからキャプチャされたすべての注文行を渡す方法がわからない。

そのメソッドを作成して、そのメソッドに注文されたものに合格していないと思います(これのポイントは、クラスではなく、クラスでは使用しないでください)

どのようにさまざまな行(NumberUnits、IdProductなどのプロパティを含むすべてのもの)を一般的なオブジェクトのリストにカプセル化できます。

は、List<List<object>>のようなものですか?

事前にありがとう!

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top