0
私はMyOrdersページで現在注文データベースのすべての注文を表示していますので、現在のアプリケーションユーザが使用した注文のみを表示する必要があります。現在のユーザ(アプリケーションユーザ)によって作成された注文を表示するためのデータベースのフィルタリング
MyOrders CSHTMLページ
@model IEnumerable<SpeedoModels.Models.Order>
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
ViewBag.Title = "MyOrders";
}
<h2>MyOrders</h2>
<h2>Orders Main</h2>
は、注文を表示し、コントローラ
で@if (User.IsInRole("Administrator"))
{
<p>
@Html.ActionLink("Create New", "Create")
</p>
}
<table class="table table-striped table-hover">
<tr>
<th>
@Html.ActionLink("First Name", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter = ViewBag.CurrentFilter })
</th>
<th>
Last Name
</th>
<th>
@Html.ActionLink("Order Total", "Index", new { sortOrder = ViewBag.PriceSortParm, currentFilter = ViewBag.CurrentFilter })
</th>
<th>
Address
</th>
<th>
City
</th>
<th>
State
</th>
<th>
Postal Code
</th>
<th>
Country
</th>
<th>
Phone
</th>
<th>
Email
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Total)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.City)
</td>
<td>
@Html.DisplayFor(modelItem => item.State)
</td>
<td>
@Html.DisplayFor(modelItem => item.PostalCode)
</td>
<td>
@Html.DisplayFor(modelItem => item.Country)
</td>
<td>
@Html.DisplayFor(modelItem => item.Phone)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
@if (User.IsInRole("Administrator"))
{
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.OrderId }) |
@Html.ActionLink("Details", "Details", new { id = item.OrderId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.OrderId })
</td>
}
@Html.ActionLink("Cancel Order", "Delete", new { id = item.OrderId })
</tr>
}
MyOrders即ちFIRSTNAMEリストはいくつかの方法で再編成することを可能にします3210
注文表のどの列にユーザー名がありますか? – User3250
電子メール列 –