mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add admin page for instruction sets by processor.
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
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;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
|
||||
namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
[Area("Admin")]
|
||||
[Authorize]
|
||||
public class InstructionSetExtensionsByProcessorController : Controller
|
||||
{
|
||||
readonly cicmContext _context;
|
||||
|
||||
public InstructionSetExtensionsByProcessorController(cicmContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
IIncludableQueryable<InstructionSetExtensionsByProcessor, Processor> cicmContext =
|
||||
_context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor);
|
||||
return View(await cicmContext.OrderBy(e => e.Processor.Name).ThenBy(e => e.Extension.Extension)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if(instructionSetExtensionsByProcessor == null) return NotFound();
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension");
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/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("Id,ProcessorId,ExtensionId")]
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
|
||||
{
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
_context.Add(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Edit/5
|
||||
public async Task<IActionResult> Edit(int? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
|
||||
if(instructionSetExtensionsByProcessor == null) return NotFound();
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/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(
|
||||
int id,
|
||||
[Bind("Id,ProcessorId,ExtensionId")]
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
|
||||
{
|
||||
if(id != instructionSetExtensionsByProcessor.Id) return NotFound();
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!InstructionSetExtensionsByProcessorExists(instructionSetExtensionsByProcessor.Id))
|
||||
return NotFound();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Delete/5
|
||||
public async Task<IActionResult> Delete(int? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if(instructionSetExtensionsByProcessor == null) return NotFound();
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/Delete/5
|
||||
[HttpPost]
|
||||
[ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(int id)
|
||||
{
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
|
||||
_context.InstructionSetExtensionsByProcessor.Remove(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
bool InstructionSetExtensionsByProcessorExists(int id)
|
||||
{
|
||||
return _context.InstructionSetExtensionsByProcessor.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@
|
||||
<a asp-controller="GpusByMachine">GPUs by machine</a><br />
|
||||
<a asp-controller="InstructionSets">Instruction sets</a><br />
|
||||
<a asp-controller="InstructionSetExtensions">Instruction set extensions</a><br />
|
||||
<a asp-controller="InstructionSetExtensionsByProcessor">Instruction set extensions by processor</a><br />
|
||||
<a asp-controller="MachineFamilies">Machine families</a><br />
|
||||
<a asp-controller="Machines">Machines</a><br />
|
||||
<a asp-controller="MemoryByMachines">Memory by machines</a><br />
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
@model Cicm.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>Instruction set extensions by processor</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="Processor"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ProcessorId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ProcessorId">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Extension"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ExtensionId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ExtensionId">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary"
|
||||
type="submit"
|
||||
value="Create" />
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
@model Cicm.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Extension.Extension)
|
||||
</dd class>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Processor.Name)
|
||||
</dd class>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden"
|
||||
asp-for="Id" />
|
||||
<input type="hidden"
|
||||
asp-for="ProcessorId" />
|
||||
<input type="hidden"
|
||||
asp-for="ExtensionId" />
|
||||
<input class="btn btn-danger"
|
||||
type="submit"
|
||||
value="Delete" />
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,37 @@
|
||||
@model Cicm.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Extension.Extension)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Processor.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>
|
||||
@@ -0,0 +1,54 @@
|
||||
@model Cicm.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly"
|
||||
class="text-danger">
|
||||
</div>
|
||||
<input type="hidden"
|
||||
asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Processor"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ProcessorId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ProcessorId">
|
||||
</select>
|
||||
<span asp-validation-for="ProcessorId"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Extension"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ExtensionId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ExtensionId">
|
||||
</select>
|
||||
<span asp-validation-for="ExtensionId"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary"
|
||||
type="submit"
|
||||
value="Save" />
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,58 @@
|
||||
@using Cicm.Database.Models
|
||||
@model IEnumerable<Cicm.Database.Models.InstructionSetExtensionsByProcessor>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Instruction set extensions by processor</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create"
|
||||
class="btn btn-primary">
|
||||
Create New
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(InstructionSetExtensionsByProcessor item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Processor.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Extension.Extension)
|
||||
</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.462</Version>
|
||||
<Version>3.0.99.466</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