mediamanager/MediaManager/Pages/EditMovie.cshtml
Laura Hausmann 2ebfd26334
Initial public git commit
Signed-off-by: Laura Hausmann <laura@hausmann.dev>
2022-09-03 01:59:27 +02:00

53 lines
2.1 KiB
Plaintext

@page "{id}"
@using MediaManager.database
@model MediaManager.Pages.EditMovie
@{
ViewData["Title"] = "Edit Movie";
if (Request.Method == "POST" && Request.Form["action"] == "delete") {
return;
}
var movie = new Database.DbConn().Movies.First(p => p.MovieId == int.Parse(RouteData.Values["id"]!.ToString()!));
if (movie.UserId != Model.AuthorizedUser.UserId) {
Response.Redirect("/");
return;
}}
<div class="text-center">
<h1 class="display-5">
Edit Movie
</h1>
</div>
<form method="POST">
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" maxlength="100" class="form-control" id="title" name="title" value="@movie.Title" autofocus required>
</div>
<div class="mb-3">
<label for="year" class="form-label">Year</label>
<input type="number" min="1800" max="2100" class="form-control" id="year" name="year" value="@movie.Year" required>
</div>
<div class="mb-3">
<label for="rating" class="form-label">Rating</label>
<input type="number" min="0" max="10" class="form-control" id="rating" name="rating" value="@movie.Rating" required>
</div>
<div class="mb-3">
<label for="rewatchability" class="form-label">Rewatchability</label>
<input type="number" min="0" max="10" class="form-control" id="rewatchability" name="rewatchability" value="@movie.Rewatchability" required>
</div>
<div class="mb-3">
<label for="watchcount" class="form-label">Watch count</label>
<input type="number" min="0" class="form-control" id="watchcount" name="watchcount" value="@movie.WatchCount" required>
</div>
<div class="mb-3">
<label for="lastwatch" class="form-label">Last watch</label>
<input type="date" class="form-control" id="lastwatch" name="lastwatch" value="@movie.LastSeen.ToString("yyyy-MM-dd")">
</div>
<div class="mb-3">
<label for="comment" class="form-label">Comment</label>
<input type="text" maxlength="100" class="form-control" id="comment" name="comment" value="@movie.Comment">
</div>
<button type="submit" class="btn btn-primary" name="action" value="save">Save</button>
<button type="submit" class="btn btn-danger" name="action" value="delete">Delete</button>
</form>