使用 Orchard 1.6 MVC,我想在屏幕上显示“供应商”列表。对于每个供应商,显示他们的产品列表和剩余数量。
Supplier 1
product 101
product 102
supplier 2
product 103
product 104
product 105
etc...
我的视图模型
public class SuppliersOrderVM
{
public IEnumerable<SupplierInfo> SupplierInformation = new List<SupplierInfo>();
public Dictionary<int, QBSupplierRecord> Suppliers { get; set; }
public Dictionary<int, QBProductRecord> Products { get; set; }
public SuppliersOrderVM(IEnumerable<SupplierInfo> supplierInformation, Dictionary<int, QBSupplierRecord> suppliers, Dictionary<int, QBProductRecord> products)
{
SupplierInformation = supplierInformation;
Suppliers = suppliers;
Products = products;
}
public class SupplierInfo
{
public int SupplierId { get; set; }
public bool SendEmail { get; set; }
public List<ProductInfo> Products = new List<ProductInfo>();
}
public class ProductInfo
{
public int ProductId { get; set; }
public int Quantity { get; set; }
}
}
所以在视图中,我使用字典来输出供应商名称。但我无法为该供应商输出产品。我的第二个 foreach 循环可能是错误的,并且我的语法对于显示产品不正确。请帮我修改
@{
foreach (var supplier in Model.SupplierInformation)
{
<div class="editor-label">@Html.Label("SupplierName")</div>
<div class="editor-label">@Model.Suppliers[supplier.SupplierId].CompanyName</div>
@* <div class="editor-label">@Html.HiddenFor(s => s.SupplierInfor[0].</div>*@
foreach (var product in Model.SupplierInformation)
{
//create table and output product code & product Quantity
<div class="editor-label">@Model.Products[product.Products].ProductCode</div>
它告诉我 [product.Products] 有一些无效的论点。