Movies are editable as well
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
}
|
||||
|
||||
<h2>Movies</h2>
|
||||
@Html.ActionLink("New Movie", "New", "Movies", null, new { @class = "btn btn-primary" })
|
||||
|
||||
@if (Model.Movies.Count == 0)
|
||||
{
|
||||
@ -12,21 +13,21 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Movie</th>
|
||||
<th>Genre</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var movie in Model.Movies)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(@movie.Name,"Movies","Movies",new { id = movie.Id },null) </td>
|
||||
<td>@movie.MovieGenre.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Movie</th>
|
||||
<th>Genre</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var movie in Model.Movies)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(@movie.Name, "Edit", "Movies", new { id = movie.Id }, null) </td>
|
||||
<td>@movie.MovieGenre.Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
37
Vidly/Views/Movies/MovieForm.cshtml
Normal file
37
Vidly/Views/Movies/MovieForm.cshtml
Normal file
@ -0,0 +1,37 @@
|
||||
@model Vidly.ViewModels.MovieFormViewModel
|
||||
@{
|
||||
ViewBag.Title = "New";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
|
||||
@if (Model.Movie.Id == null || Model.Movie.Id == 0)
|
||||
{
|
||||
<h2>New Movie</h2>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h2>Edit Movie</h2>
|
||||
}
|
||||
|
||||
@using (Html.BeginForm("Save", "Movies"))
|
||||
{
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Movie.Name)
|
||||
@Html.TextBoxFor(m => m.Movie.Name, new { @class = "form-control" })
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Movie.ReleaseDate)
|
||||
@Html.TextBoxFor(m => m.Movie.ReleaseDate, "{0:d MMM yyyy}", new { @class = "form-control" })
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Movie.MovieGenreId)
|
||||
@Html.DropDownListFor(m => m.Movie.MovieGenreId, new SelectList(Model.MovieGenres, "Id", "Name"), "Select Genre Type", new { @class = "form-control" })
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Movie.NumberInStock)
|
||||
@Html.TextBoxFor(m => m.Movie.NumberInStock, new { @class = "form-control" })
|
||||
</div>
|
||||
@Html.HiddenFor(m=>m.Movie.Id)
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
}
|
||||
Reference in New Issue
Block a user