0

次のビュー コードでは、243 行目の "foreach" ループを、出荷日、配送業者、および追跡番号を一度だけ返すものに置き換える必要があります。現在、コードは各発送パッケージの発送日、運送業者、および追跡番号を返します。したがって、3 つのパッケージがある場合、各行は各行で同じ情報を 3 回返します。出荷パッケージごとに 1 回表示したいのですが。

この既に開発されたプロジェクトに取り組んで、ASP と MVC を学ぼうとしています。さらに情報が必要な場合はお知らせください。

@model InSite.Mvc.Models.ViewModels.OrderHistoryDetailViewModel
@section TemplateCssContent
{
<link href="/Styles/template/ma-order-details.css" rel="stylesheet" type="text/css" />
<link href="/Styles/print.css" rel="stylesheet" type="text/css" media="print" />
}
<div class="midwrapper2">
<div class="contentArea2">
    <div class="mavd-wrapper">
        @{ Html.RenderAction("MyAccountLeftNav", "Shared"); }
        <div class="contentWrapper2">
            <div class="content2">
                <div class="clr lfl w100">
                    <h1>
                        Order Detail</h1>
                    <div class="return-btn">
                        <a class="btn btnStyleC btn-back-order" href="@Url.Action("OrderHistory", "Account")">
                            Back to Order List</a></div>
                </div>
                @if (Model.ErpError.Length > 0)
                {
                    <div class="clr lfl w100 error">
                        @Html.Raw(Model.ErpError)
                    </div>
                }
                else
                {
                    <div class="clr lfl w100">
                        <div class="order-number-date">
                            <table>
                                <tr>
                                    <th class="col-1">
                                        <h3>
                                            Order #:</h3>
                                    </th>
                                    <td class="col-2">
                                        <h3>@Model.CustomerOrder.OrderNumber</h3>
                                    </td>
                                </tr>
                                <tr>
                                    <th class="col-1">
                                        <h3>
                                            Order Date:</h3>
                                    </th>
                                    <td class="col-2">
                                        <h3>@Model.CustomerOrder.OrderDate.ToShortDateString()</h3>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        @if (Model.WSC_ShowPONumber || Model.WSC_ShowTermsCode)
                        {
                            <div class="order-number-date">
                                <table>
                                    @if (Model.WSC_ShowPONumber)
                                    { 
                                        <tr>
                                            <th class="col-1">
                                                <h3>
                                                    PO#:</h3>
                                            </th>
                                            <td class="col-2">
                                                <h3>@Model.CustomerOrder.CustomerPO</h3>
                                            </td>
                                        </tr>
                                    }
                                    @if (Model.WSC_ShowTermsCode)
                                    {
                                        <tr>
                                            <th class="col-1">
                                                <h3>
                                                    Terms:</h3>
                                            </th>
                                            <td class="col-2">
                                                <h3>@Model.CustomerOrder.TermsCode</h3>
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                        }
                    </div>
                    <div class="clr lfl w100">
                        <div class="bill-ship">
                            <table>
                                <tr>
                                    <th>
                                        <h4>
                                            Billing Information</h4>
                                    </th>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.BTDisplayName
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Html.Raw(Model.CustomerOrder.BTAddress1)
                                    </td>
                                </tr>
                                @if (!String.IsNullOrEmpty(Model.CustomerOrder.BTAddress2))
                                { 
                                    <tr>
                                        <td>
                                            @Html.Raw(Model.CustomerOrder.BTAddress2)
                                        </td>
                                    </tr>
                                }
                                <tr>
                                    <td>
                                        @Html.CityCommaStateZip(Model.CustomerOrder.BTCity, Model.CustomerOrder.BTState, Model.CustomerOrder.BTZip)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.BTCountry
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.BTPhone1
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.BTEmail
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="bill-ship">
                            <table>
                                <tr>
                                    <th>
                                        <h4>
                                            Shipping Information</h4>
                                    </th>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.STDisplayName
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Html.Raw(Model.CustomerOrder.STAddress1)
                                    </td>
                                </tr>
                                @if (!String.IsNullOrEmpty(Model.CustomerOrder.STAddress2))
                                { 
                                    <tr>
                                        <td>
                                            @Html.Raw(Model.CustomerOrder.STAddress2)
                                        </td>
                                    </tr>
                                }
                                <tr>
                                    <td>
                                        @Html.CityCommaStateZip(Model.CustomerOrder.STCity, Model.CustomerOrder.STState, Model.CustomerOrder.STZip)
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.STCountry
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.STPhone1
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        @Model.CustomerOrder.STEmail
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="clr lfl w100">
                        <table class="info-tbl tbl-1">
                            <tr>
                                <th class="od-item">
                                    Item #
                                </th>
                                <th class="od-desc">
                                    Item Description
                                </th>
                                <th class="od-qty">
                                    Qty Ordered
                                </th>

                                @if (Model.CustomerOrder.ShipmentPackages.Count > 0)
                                    { 


                                    <th class="od-ship">
                                        Ship Date
                                    </th>
                                    <th class="od-pack">
                                        Carrier
                                    </th>

                                    <th class="od-track">
                                        Tracking #
                                    </th>
                                    }

                                <th class="od-unit">
                                    Unit Price
                                </th>
                                <th class="od-ext">
                                    Extended Price
                                </th>
                            </tr>



                            @foreach (var orderLine in Model.CustomerOrder.OrderLines)
                            { 
                                <tr>
                                    <td class="od-item">
                                        @if (orderLine.ProductRoute != null)
                                        {
                                            <a href="@Url.RouteUrl(null, orderLine.ProductRoute)">@orderLine.ERPNumber</a>
                                        }
                                        else
                                        {
                                            @orderLine.ERPNumber
                                        }
                                    </td>
                                    <td class="od-desc">
                                        @orderLine.ShortDescription
                                    </td>
                                    <td class="od-qty">
                                        @String.Format("{0:0}", orderLine.QtyOrdered)
                                    </td>




                                    @foreach (var shipmentPackage in Model.CustomerOrder.ShipmentPackages)
                                        {
                                    <td class="od-ship">
                                            @shipmentPackage.ShipmentDate.ToShortDateString()
                                        </td>
                                        <td class="od-pack">
                                            @shipmentPackage.Carrier
                                        </td>

                                        <td class="od-track">
                                            @if (String.IsNullOrEmpty(shipmentPackage.TrackingURL))
                                            {
                                                @shipmentPackage.TrackingNumber
                                            }
                                            else
                                            {
                                                <a target= "_blank" href="@shipmentPackage.TrackingURL" >
                                                    @shipmentPackage.TrackingNumber</a>   
                                            }
                                        </td>

                                     }
                                    <td class="od-unit">
                                        @orderLine.ActualPrice.ToCurrency()
                                    </td>
                                    <td class="od-ext">
                                        @orderLine.ExtendedActualPrice.ToCurrency()
                                    </td>
                                </tr>
                            }
                        </table>

                    </div>
                    <div class="clr lfl w100">
                        <table class="tbl-total">
                            <tr class="subtotal">
                                <th class="col-1">
                                    Subtotal
                                </th>
                                <th class="col-2">@Model.CustomerOrder.OrderSubTotal.ToCurrency()
                                </th>
                            </tr>
                            @if (Model.CustomerOrder.DollarOffOrder > 0)
                            { 
                                <tr>
                                    <th class="col-1">
                                        Order Discount
                                    </th>
                                    <th class="col-2">@Model.CustomerOrder.DollarOffOrder.ToCurrency()
                                    </th>
                                </tr>
                            }
                            <tr>
                                <th class="col-1">
                                    Shipping Amount
                                </th>
                                <th class="col-2">@Model.CustomerOrder.ShippingAndHandling.ToCurrency()
                                </th>
                            </tr>
                            @if (Model.CustomerOrder.DollarOffShipping > 0)
                            { 
                                <tr>
                                    <th class="col-1">
                                        Shipping Discount
                                    </th>
                                    <th class="col-2">@Model.CustomerOrder.DollarOffShipping.ToCurrency()
                                    </th>
                                </tr>
                            }
                            <tr>
                                <th class="col-1">
                                    Sales Tax
                                </th>
                                <th class="col-2">@Model.CustomerOrder.TotalTax.ToCurrency()
                                </th>
                            </tr>
                            <tr class="total">
                                <th class="col-1">
                                    Order Total
                                </th>
                                <th class="col-2">@Model.CustomerOrder.OrderGrandTotal.ToCurrency()
                                </th>
                            </tr>
                        </table>
                    </div>
                    <div class="clr lfl w100 order-btns">
  <a class="btn btnStyleB btn-print" href="javascript:window.print();">Print</a> <a class="btn btnStyleA btn-rma" href="@Url.RouteUrl(new { controller = "Account", action = "RequestRma", orderId = String.IsNullOrEmpty(Model.CustomerOrder.ERPOrderNumber) ? Model.CustomerOrder.OrderNumber : Model.CustomerOrder.ERPOrderNumber })">
                            Return Request (RMA)</a>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
</div>
<div class="reverse-footer">
</div>
4

1 に答える 1