mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add admin page for resolution by GPU.
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class ResolutionsByGpu
|
||||
@@ -36,6 +38,7 @@ namespace Cicm.Database.Models
|
||||
public int ResolutionId { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
[DisplayName("GPU")]
|
||||
public virtual Gpu Gpu { get; set; }
|
||||
public virtual Resolution Resolution { get; set; }
|
||||
}
|
||||
|
||||
173
cicm_web/Areas/Admin/Controllers/ResolutionsByGpuController.cs
Normal file
173
cicm_web/Areas/Admin/Controllers/ResolutionsByGpuController.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
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 ResolutionsByGpuController : Controller
|
||||
{
|
||||
readonly cicmContext _context;
|
||||
|
||||
public ResolutionsByGpuController(cicmContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: ResolutionsByGpu
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
IIncludableQueryable<ResolutionsByGpu, Resolution> cicmContext =
|
||||
_context.ResolutionsByGpu.Include(r => r.Gpu).Include(r => r.Resolution);
|
||||
return View(await cicmContext.OrderBy(r => r.Gpu.Company.Name).ThenBy(r => r.Gpu.Name)
|
||||
.ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Width)
|
||||
.ThenBy(r => r.Resolution.Height).ThenBy(r => r.Resolution.Colors)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: ResolutionsByGpu/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu
|
||||
.Include(r => r.Gpu).Include(r => r.Resolution)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if(resolutionsByGpu == null) return NotFound();
|
||||
|
||||
return View(resolutionsByGpu);
|
||||
}
|
||||
|
||||
// GET: ResolutionsByGpu/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["GpuId"] =
|
||||
new
|
||||
SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).Select(g => new {g.Id, Name = $"{g.Company.Name} {g.Name}"}),
|
||||
"Id", "Name");
|
||||
ViewData["ResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: ResolutionsByGpu/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("GpuId,ResolutionId,Id")] ResolutionsByGpu resolutionsByGpu)
|
||||
{
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
_context.Add(resolutionsByGpu);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["GpuId"] =
|
||||
new
|
||||
SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).Select(g => new {g.Id, Name = $"{g.Company.Name} {g.Name}"}),
|
||||
"Id", "Name", resolutionsByGpu.GpuId);
|
||||
ViewData["ResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name", resolutionsByGpu.ResolutionId);
|
||||
return View(resolutionsByGpu);
|
||||
}
|
||||
|
||||
// GET: ResolutionsByGpu/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu.FindAsync(id);
|
||||
if(resolutionsByGpu == null) return NotFound();
|
||||
|
||||
ViewData["GpuId"] =
|
||||
new
|
||||
SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).Select(g => new {g.Id, Name = $"{g.Company.Name} {g.Name}"}),
|
||||
"Id", "Name", resolutionsByGpu.GpuId);
|
||||
ViewData["ResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name", resolutionsByGpu.ResolutionId);
|
||||
return View(resolutionsByGpu);
|
||||
}
|
||||
|
||||
// POST: ResolutionsByGpu/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("GpuId,ResolutionId,Id")] ResolutionsByGpu resolutionsByGpu)
|
||||
{
|
||||
if(id != resolutionsByGpu.Id) return NotFound();
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(resolutionsByGpu);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!ResolutionsByGpuExists(resolutionsByGpu.Id)) return NotFound();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["GpuId"] =
|
||||
new
|
||||
SelectList(_context.Gpus.OrderBy(r => r.Company.Name).ThenBy(r => r.Name).Select(g => new {g.Id, Name = $"{g.Company.Name} {g.Name}"}),
|
||||
"Id", "Name", resolutionsByGpu.GpuId);
|
||||
ViewData["ResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name", resolutionsByGpu.ResolutionId);
|
||||
return View(resolutionsByGpu);
|
||||
}
|
||||
|
||||
// GET: ResolutionsByGpu/Delete/5
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu
|
||||
.Include(r => r.Gpu).Include(r => r.Resolution)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
if(resolutionsByGpu == null) return NotFound();
|
||||
|
||||
return View(resolutionsByGpu);
|
||||
}
|
||||
|
||||
// POST: ResolutionsByGpu/Delete/5
|
||||
[HttpPost]
|
||||
[ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
ResolutionsByGpu resolutionsByGpu = await _context.ResolutionsByGpu.FindAsync(id);
|
||||
_context.ResolutionsByGpu.Remove(resolutionsByGpu);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
bool ResolutionsByGpuExists(long id)
|
||||
{
|
||||
return _context.ResolutionsByGpu.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@
|
||||
<a asp-controller="ProcessorsByMachines">Processors by machines</a><br />
|
||||
<a asp-controller="Processors">Processors</a><br />
|
||||
<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="StorageByMachines">Storage by machines</a><br />
|
||||
</div>
|
||||
|
||||
46
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml
Normal file
46
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml
Normal file
@@ -0,0 +1,46 @@
|
||||
@model Cicm.Database.Models.ResolutionsByGpu
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h1>Create</h1>
|
||||
|
||||
<h4>Resolutions by GPU</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="Gpu"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="GpuId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.GpuId">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Resolution"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ResolutionId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ResolutionId">
|
||||
</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>
|
||||
39
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml
Normal file
39
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml
Normal file
@@ -0,0 +1,39 @@
|
||||
@model Cicm.Database.Models.ResolutionsByGpu
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Resolution by GPU</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Resolution)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Model.Resolution.ToString()
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden"
|
||||
asp-for="Id" />
|
||||
<input class="btn btn-danger"
|
||||
type="submit"
|
||||
value="Delete" />
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
37
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml
Normal file
37
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml
Normal file
@@ -0,0 +1,37 @@
|
||||
@model Cicm.Database.Models.ResolutionsByGpu
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>Resolution by GPU</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Gpu.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Resolution)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Model.Resolution.ToString()
|
||||
</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>
|
||||
54
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml
Normal file
54
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml
Normal file
@@ -0,0 +1,54 @@
|
||||
@model Cicm.Database.Models.ResolutionsByGpu
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
|
||||
<h1>Edit</h1>
|
||||
|
||||
<h4>Resolution by GPU</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="GpuId"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="GpuId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.GpuId">
|
||||
</select>
|
||||
<span asp-validation-for="GpuId"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ResolutionId"
|
||||
class="control-label">
|
||||
</label>
|
||||
<select asp-for="ResolutionId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.ResolutionId">
|
||||
</select>
|
||||
<span asp-validation-for="ResolutionId"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<input type="hidden"
|
||||
asp-for="Id" />
|
||||
<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>
|
||||
59
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml
Normal file
59
cicm_web/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml
Normal file
@@ -0,0 +1,59 @@
|
||||
@using Cicm.Database.Models
|
||||
@model IEnumerable<Cicm.Database.Models.ResolutionsByGpu>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Resolutions by GPU</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create"
|
||||
class="btn btn-primary">
|
||||
Create New
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Gpu)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Resolution)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(ResolutionsByGpu item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Gpu.Company.Name)
|
||||
@Html.DisplayFor(modelItem => item.Gpu.Name)
|
||||
</td>
|
||||
<td>
|
||||
@item.Resolution
|
||||
</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.466</Version>
|
||||
<Version>3.0.99.477</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