How to create a Master Parts view using an Asp.Net MVC structure

I have been evaluating the ASP.NET MVC framework over the past couple of weeks for our enterprise application. One thing I'm trying to achieve is the presentation of the "Master Detail". How clear it is that there is no look and no reverse gear. For example, I use the Products, Customers, Orders and Order Details table from the Northwind database and using Asp.Net MVC. I want to create a Master Parts view. Basically, I don’t want to have separate views (on other pages) for order and order details. The submission should consist of a description of the order and the order. How do I create a controller and view it to achieve this functionality.

Thanks and Regards, Burhanuddin Ghi Vala

+4
source share
2 answers

You would like to write a viewmodel class class for a domain that combines all the data from one order and its OrderDetails (I assume that the relation Order> OrderDetails, not familiar with Northwind, has the relation 1-> N):

public class OrderViewModel { public Order Order {get;set;} public IEnumerable<OrderDetail> OrderDetails{get;set;} } 

Create a View template that binds to this type, creating order and order data on one page.

In the controller class, write an action method that will populate one instance of the OrderViewModel class and pass it to the View template.

+6
source

You should consider placing partial order details to make your order type small. You can also reuse this snippet elsewhere in the application.

0
source

Source: https://habr.com/ru/post/1286735/


All Articles