Fix old names for Create action. Remove ID hidden field from game add view. Clean up archive adding view. Add button to add additional archives.
parent
5bcf8d3e3c
commit
3000985a53
|
@ -47,16 +47,25 @@ namespace LANCommander.Controllers
|
|||
{
|
||||
var game = await gameRepo.Find(id.GetValueOrDefault());
|
||||
|
||||
using (Repository<Archive> archiveRepo = new Repository<Archive>(Context, HttpContext))
|
||||
{
|
||||
archive.Game = game;
|
||||
|
||||
if (game.Archives != null && game.Archives.Any(a => a.Version == archive.Version))
|
||||
ModelState.AddModelError("Version", "An archive for this game is already using that version.");
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
using (Repository<Archive> archiveRepo = new Repository<Archive>(Context, HttpContext))
|
||||
{
|
||||
archive = await archiveRepo.Add(archive);
|
||||
await archiveRepo.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("Edit", "Games", new { id = id });
|
||||
}
|
||||
}
|
||||
|
||||
return View(archive);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Download(Guid id)
|
||||
{
|
||||
|
|
|
@ -4,53 +4,72 @@
|
|||
ViewData["Title"] = "Add Archive";
|
||||
}
|
||||
|
||||
<h1>Add Archive</h1>
|
||||
<div class="container-xl">
|
||||
<!-- Page title -->
|
||||
<div class="page-header d-print-none">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<div class="page-pretitle">@Model.Game.Title</div>
|
||||
<h2 class="page-title">
|
||||
Add Archive
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4>@Html.DisplayFor(m => m.Game.Title)</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<form asp-action="Add" enctype="multipart/form-data" >
|
||||
<div class="page-body">
|
||||
<div class="container-xl">
|
||||
<div class="row row-cards">
|
||||
<div class="col-12">
|
||||
<form asp-action="Add" enctype="multipart/form-data" class="card">
|
||||
<fieldset>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
|
||||
<div class="mb-3">
|
||||
<label asp-for="Version" class="control-label"></label>
|
||||
<input asp-for="Version" class="form-control" />
|
||||
<span asp-validation-for="Version" class="text-danger"></span>
|
||||
@if (Model.LastVersion != null && !String.IsNullOrWhiteSpace(Model.LastVersion.Version))
|
||||
{
|
||||
<small class="form-hint">Last version: @Model.LastVersion.Version</small>
|
||||
}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="mb-3">
|
||||
<label asp-for="Changelog" class="control-label"></label>
|
||||
<textarea asp-for="Changelog" class="form-control"></textarea>
|
||||
<span asp-validation-for="Changelog" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="mb-3">
|
||||
<label for="File" class="control-label">File</label>
|
||||
<input type="file" id="File" class="form-control" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Last Version</label>
|
||||
<input class="form-control" value="@Html.DisplayFor(m => m.LastVersion.Version)" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="progress">
|
||||
<div>
|
||||
<div class="progress h-4">
|
||||
<div class="progress-bar" role="progressbar" style="width: 0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="hidden" asp-for="ObjectKey" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="d-flex">
|
||||
<a asp-action="Edit" asp-controller="Games" asp-route-id="@Model.Game.Id" class="btn btn-link">Cancel</a>
|
||||
<button class="btn btn-primary" id="UploadButton">Upload</button>
|
||||
<input type="submit" value="Save" id="SaveButton" class="btn btn-primary" style="display: none;" />
|
||||
</div>
|
||||
|
||||
<input type="hidden" asp-for="ObjectKey" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@model LANCommander.Data.Models.Game
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
ViewData["Title"] = "Add Game";
|
||||
}
|
||||
|
||||
<div class="container-xl">
|
||||
|
@ -10,7 +10,7 @@
|
|||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h2 class="page-title">
|
||||
Create Game
|
||||
Add Game
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,7 +21,7 @@
|
|||
<div class="container-xl">
|
||||
<div class="row row-cards">
|
||||
<div class="col-12">
|
||||
<form asp-action="Edit" class="card">
|
||||
<form asp-action="Add" class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
@ -47,8 +47,6 @@
|
|||
<input asp-for="ReleasedOn" class="form-control" />
|
||||
<span asp-validation-for="ReleasedOn" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<input type="hidden" asp-for="Id" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -67,7 +67,19 @@
|
|||
@if (Model.Archives != null && Model.Archives.Count > 0)
|
||||
{
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">Archives</h3>
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h3 class="card-title mb-0">Archives</h3>
|
||||
</div>
|
||||
<div class="col-auto ms-auto">
|
||||
<div class="d-flex">
|
||||
<a asp-action="Add" asp-controller="Archives" asp-route-id="@Model.Id" class="btn btn-primary">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
||||
Add
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
|
@ -91,7 +103,7 @@
|
|||
<td>@Html.DisplayFor(m => archive.CreatedOn)</td>
|
||||
<td>@ByteSizeLib.ByteSize.FromBytes(new FileInfo(System.IO.Path.Combine("Upload", archive.ObjectKey)).Length)</td>
|
||||
<td>
|
||||
<div class="btn-list flex-nowrap">
|
||||
<div class="btn-list flex-nowrap justify-content-end">
|
||||
<a asp-action="Download" asp-controller="Archives" asp-route-id="@archive.Id" class="btn">Download</a>
|
||||
<a asp-action="Delete" asp-controller="Archives" asp-route-id="@archive.Id" class="btn btn-danger">Delete</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue