mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add admin page for sound by machine.
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class SoundByMachine
|
||||
@@ -37,6 +39,7 @@ namespace Cicm.Database.Models
|
||||
public long Id { get; set; }
|
||||
|
||||
public virtual Machine Machine { get; set; }
|
||||
[DisplayName("Sound synthetizer")]
|
||||
public virtual SoundSynth SoundSynth { get; set; }
|
||||
}
|
||||
}
|
||||
166
cicm_web/Areas/Admin/Controllers/SoundByMachineController.cs
Normal file
166
cicm_web/Areas/Admin/Controllers/SoundByMachineController.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
[Area("Admin")]
|
||||
[Authorize]
|
||||
public class SoundByMachineController : Controller
|
||||
{
|
||||
private readonly cicmContext _context;
|
||||
|
||||
public SoundByMachineController(cicmContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: SoundByMachine
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var cicmContext = _context.SoundByMachine.Include(s => s.Machine).Include(s => s.SoundSynth);
|
||||
return View(await cicmContext.OrderBy(s => s.Machine.Name).ThenBy(s => s.SoundSynth.Name).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: SoundByMachine/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var soundByMachine = await _context.SoundByMachine
|
||||
.Include(s => s.Machine)
|
||||
.Include(s => s.SoundSynth)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if (soundByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(soundByMachine);
|
||||
}
|
||||
|
||||
// GET: SoundByMachine/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name");
|
||||
ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: SoundByMachine/Create
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create([Bind("SoundSynthId,MachineId,Id")] SoundByMachine soundByMachine)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Add(soundByMachine);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId);
|
||||
ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId);
|
||||
return View(soundByMachine);
|
||||
}
|
||||
|
||||
// GET: SoundByMachine/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var soundByMachine = await _context.SoundByMachine.FindAsync(id);
|
||||
if (soundByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId);
|
||||
ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId);
|
||||
return View(soundByMachine);
|
||||
}
|
||||
|
||||
// POST: SoundByMachine/Edit/5
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(long id, [Bind("SoundSynthId,MachineId,Id")] SoundByMachine soundByMachine)
|
||||
{
|
||||
if (id != soundByMachine.Id)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(soundByMachine);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!SoundByMachineExists(soundByMachine.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", soundByMachine.MachineId);
|
||||
ViewData["SoundSynthId"] = new SelectList(_context.SoundSynths, "Id", "Name", soundByMachine.SoundSynthId);
|
||||
return View(soundByMachine);
|
||||
}
|
||||
|
||||
// GET: SoundByMachine/Delete/5
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var soundByMachine = await _context.SoundByMachine
|
||||
.Include(s => s.Machine)
|
||||
.Include(s => s.SoundSynth)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if (soundByMachine == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(soundByMachine);
|
||||
}
|
||||
|
||||
// POST: SoundByMachine/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
var soundByMachine = await _context.SoundByMachine.FindAsync(id);
|
||||
_context.SoundByMachine.Remove(soundByMachine);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
private bool SoundByMachineExists(long id)
|
||||
{
|
||||
return _context.SoundByMachine.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@
|
||||
<a asp-controller="Resolutions">Resolutions</a><br />
|
||||
<a asp-controller="ResolutionsByGpu">Resolutions by GPU</a><br />
|
||||
<a asp-controller="SoundSynths">Sound synthetizers</a><br />
|
||||
<a asp-controller="SoundByMachine">Sound synthetizers by machine</a><br />
|
||||
<a asp-controller="StorageByMachines">Storage by machines</a><br />
|
||||
</div>
|
||||
|
||||
|
||||
30
cicm_web/Areas/Admin/Views/SoundByMachine/Create.cshtml
Normal file
30
cicm_web/Areas/Admin/Views/SoundByMachine/Create.cshtml
Normal file
@@ -0,0 +1,30 @@
|
||||
@model Cicm.Database.Models.SoundByMachine
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>Sound by machine</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SoundSynth" class="control-label"></label>
|
||||
<select asp-for="SoundSynthId" class ="form-control" asp-items="ViewBag.SoundSynthId"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Machine" class="control-label"></label>
|
||||
<select asp-for="MachineId" class ="form-control" asp-items="ViewBag.MachineId"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
33
cicm_web/Areas/Admin/Views/SoundByMachine/Delete.cshtml
Normal file
33
cicm_web/Areas/Admin/Views/SoundByMachine/Delete.cshtml
Normal file
@@ -0,0 +1,33 @@
|
||||
@model Cicm.Database.Models.SoundByMachine
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Sound by machine</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Machine.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.SoundSynth)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.SoundSynth.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<input type="submit" value="Delete" class="btn btn-danger" />
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
</form>
|
||||
</div>
|
||||
30
cicm_web/Areas/Admin/Views/SoundByMachine/Details.cshtml
Normal file
30
cicm_web/Areas/Admin/Views/SoundByMachine/Details.cshtml
Normal file
@@ -0,0 +1,30 @@
|
||||
@model Cicm.Database.Models.SoundByMachine
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Sound by machine</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.Machine.Name)
|
||||
</dd>
|
||||
<dt class = "col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.SoundSynth)
|
||||
</dt>
|
||||
<dd class = "col-sm-10">
|
||||
@Html.DisplayFor(model => model.SoundSynth.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
</div>
|
||||
33
cicm_web/Areas/Admin/Views/SoundByMachine/Edit.cshtml
Normal file
33
cicm_web/Areas/Admin/Views/SoundByMachine/Edit.cshtml
Normal file
@@ -0,0 +1,33 @@
|
||||
@model Cicm.Database.Models.SoundByMachine
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>Sound by machine</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SoundSynth" class="control-label"></label>
|
||||
<select asp-for="SoundSynthId" class="form-control" asp-items="ViewBag.SoundSynthId"></select>
|
||||
<span asp-validation-for="SoundSynthId" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Machine" class="control-label"></label>
|
||||
<select asp-for="MachineId" class="form-control" asp-items="ViewBag.MachineId"></select>
|
||||
<span asp-validation-for="MachineId" class="text-danger"></span>
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Save" class="btn btn-primary" />
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
41
cicm_web/Areas/Admin/Views/SoundByMachine/Index.cshtml
Normal file
41
cicm_web/Areas/Admin/Views/SoundByMachine/Index.cshtml
Normal file
@@ -0,0 +1,41 @@
|
||||
@model IEnumerable<Cicm.Database.Models.SoundByMachine>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Sound synthetizers by machine</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create" class="btn btn-primary">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Machine)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SoundSynth)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Machine.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SoundSynth.Name)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">Details</a>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">Edit</a>
|
||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.479</Version>
|
||||
<Version>3.0.99.483</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user