Hi,
According to my requirement, i have created Model classes like Blocks,Slabs,CustDetails, CustFeedback, CustOrders classes .
Next i created context class for them.
Now i want to use all these classes in Home Controller.Is it possible?
Should i use multiple controllers for them?
Till now i know how to work with single model class in controller.Please suggest
My project is as given below.
There will be login page.
If Admin logged in ,then he can view total blocks and slabs.He can insert,update,delete blocks and slabs.He can view customers orders.He can view customer feedbacks.
If Customers logged in ,then he can view all blocks and slabs available.He can send an order to buy any desired block or slab .He can send feedback or complaints to admin.
My Database tables are:
Blocks,Slabs,CustDetails, CustFeedback, CustOrders .
I created model classes and context classes for them.How to use them in my Home controller.
Generally for single model class ,we do as below while creating controller
Controller Name: Home
Model Class: Block
Data Context Class: MyBlock
then how to do with multiple model classes? Please give me suggestions
How to use multiple model classes in one controller in MVC?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Devinder KumarRank #3,050 · 465 pointsPosted Jan 13, 2014, 8:11 PM EST
Create a parent view model that contains both models. public class MainPageModel{ public Model1 Model1{get; set;} public Model2 Model2{get; set;} }