一、创建movie的视图
二、对cinema、movie视图添加‘添加信息’的操作
一、创建movie的视图
在views文件夹下添加Movie文件夹,在这个文件夹下添加Index.cshtml视图,为什么添加Index.cshtml这个名字的视图,可以看看我们写的MovieController控制器
@using DemoCoreStudy.Models
@model IEnumerable<Movie>
<div class="container">
<div class="row">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Staring</th>
<th scope="col">ReleseDate</th>
<th></th>
</tr>
</thead>
<tbody>
@Html.DisplayForModel()
</tbody>
</table>
</div>
</div>
然后再Movie文件夹下添加DispalyTemplates文件夹,其中添加Movie.cshtml视图
@model DemoCoreStudy.Models.Movie
<tr>
<th scope="col">@Model.Id</th>
<td>@Model.Name</td>
<td>@Model.Starring</td>
<td>@Model.ReleseDate</td>
<td asp-action="Edit" asp-route-movieId="@Model.Id">编辑</td>
</tr>
接下来回到MovieController控制器添加Edit方法
public IActionResult Edit(int movieId)
{
return RedirectToAction("Index");
}
``
`然后我们回到Cinema.cshtml,写下一个跳转链接,点一下电影名可以跳转到对应的的电影界面
@model DemoCoreStudy.Models.Cinema
@Model.Id @Model.Name @Model.Location @Model.Capacity 编辑 `