简体   繁体   中英

Target a model class with a different name than the controller

I have an entity "orders" which is used for administrative views to access all orders in the system.

I want to use the same entity to allow non-administrative users to view and manage their own orders.

My methodology would be to create a controller called userorders to keep everything separate from the existing orders controller. This controller would target a view model named "userorders". However, the entity and table name is "orders", so I'm not able to create this controller.

Is it possible to create a controller that targets the orders entity but has a different name?

Is there a better way to go about this?

You should probably create a UserOder view model for that case and when you are ready to persist your UserOrder, convert it back to your Order entity.

There are no reason you could not create a controller to manipulate those UserOrder, since Entity is only used to hide the direct database manipulation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM