From 8ce6361b26eaca5e580b605fd1ff1fae7e035651 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 30 May 2020 04:36:31 +0100 Subject: [PATCH] Add resolutions to admin view. --- .../Controllers/ResolutionsByGpuController.cs | 206 --------------- .../ResolutionsByScreenController.cs | 197 --------------- .../Controllers/ResolutionsController.cs | 159 ------------ .../Admin/Views/Resolutions/Create.cshtml | 99 -------- .../Admin/Views/Resolutions/Delete.cshtml | 87 ------- .../Admin/Views/Resolutions/Details.cshtml | 87 ------- .../Areas/Admin/Views/Resolutions/Edit.cshtml | 100 -------- .../Admin/Views/Resolutions/Index.cshtml | 73 ------ .../Views/ResolutionsByGpu/Create.cshtml | 38 --- .../Views/ResolutionsByGpu/Delete.cshtml | 32 --- .../Views/ResolutionsByGpu/Details.cshtml | 32 --- .../Admin/Views/ResolutionsByGpu/Edit.cshtml | 39 --- .../Admin/Views/ResolutionsByGpu/Index.cshtml | 49 ---- .../Views/ResolutionsByScreen/Create.cshtml | 42 ---- .../Views/ResolutionsByScreen/Delete.cshtml | 39 --- .../Views/ResolutionsByScreen/Details.cshtml | 39 --- .../Views/ResolutionsByScreen/Edit.cshtml | 41 --- .../Views/ResolutionsByScreen/Index.cshtml | 55 ---- Marechai/Marechai.csproj | 23 +- Marechai/Pages/Admin/Details/Gpu.razor | 104 +++++++- Marechai/Pages/Admin/Details/Gpu.razor.cs | 131 ++++++++-- Marechai/Pages/Admin/Details/Resolution.razor | 131 ++++++++++ .../Pages/Admin/Details/Resolution.razor.cs | 104 ++++++++ Marechai/Pages/Admin/Details/Screen.razor | 106 +++++++- Marechai/Pages/Admin/Details/Screen.razor.cs | 118 ++++++++- Marechai/Pages/Admin/Index.razor | 3 + Marechai/Pages/Admin/Resolutions.razor | 118 +++++++++ Marechai/Pages/Admin/Resolutions.razor.cs | 52 ++++ .../Resources/Services/AdminService.es.resx | 4 + .../Resources/Services/GpusService.en.resx | 4 + .../Resources/Services/GpusService.es.resx | 48 ++++ .../Services/ResolutionsService.en.resx | 129 ++++++++++ .../Services/ResolutionsService.es.resx | 237 ++++++++++++++++++ .../Resources/Services/ScreensService.en.resx | 4 + .../Resources/Services/ScreensService.es.resx | 48 ++++ Marechai/Services/Register.cs | 3 + Marechai/Services/ResolutionsByGpuService.cs | 56 +++++ .../Services/ResolutionsByScreenService.cs | 56 +++++ Marechai/Services/ResolutionsService.cs | 57 ++++- .../ViewModels/ResolutionByGpuViewModel.cs | 9 + .../ViewModels/ResolutionByScreenViewModel.cs | 9 + 41 files changed, 1518 insertions(+), 1450 deletions(-) delete mode 100644 Marechai/Areas/Admin/Controllers/ResolutionsByGpuController.cs delete mode 100644 Marechai/Areas/Admin/Controllers/ResolutionsByScreenController.cs delete mode 100644 Marechai/Areas/Admin/Controllers/ResolutionsController.cs delete mode 100644 Marechai/Areas/Admin/Views/Resolutions/Create.cshtml delete mode 100644 Marechai/Areas/Admin/Views/Resolutions/Delete.cshtml delete mode 100644 Marechai/Areas/Admin/Views/Resolutions/Details.cshtml delete mode 100644 Marechai/Areas/Admin/Views/Resolutions/Edit.cshtml delete mode 100644 Marechai/Areas/Admin/Views/Resolutions/Index.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByScreen/Create.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByScreen/Delete.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByScreen/Details.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByScreen/Edit.cshtml delete mode 100644 Marechai/Areas/Admin/Views/ResolutionsByScreen/Index.cshtml create mode 100644 Marechai/Pages/Admin/Details/Resolution.razor create mode 100644 Marechai/Pages/Admin/Details/Resolution.razor.cs create mode 100644 Marechai/Pages/Admin/Resolutions.razor create mode 100644 Marechai/Pages/Admin/Resolutions.razor.cs create mode 100644 Marechai/Resources/Services/ResolutionsService.en.resx create mode 100644 Marechai/Resources/Services/ResolutionsService.es.resx create mode 100644 Marechai/Services/ResolutionsByGpuService.cs create mode 100644 Marechai/Services/ResolutionsByScreenService.cs create mode 100644 Marechai/ViewModels/ResolutionByGpuViewModel.cs create mode 100644 Marechai/ViewModels/ResolutionByScreenViewModel.cs diff --git a/Marechai/Areas/Admin/Controllers/ResolutionsByGpuController.cs b/Marechai/Areas/Admin/Controllers/ResolutionsByGpuController.cs deleted file mode 100644 index 87f18d07..00000000 --- a/Marechai/Areas/Admin/Controllers/ResolutionsByGpuController.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Marechai.Areas.Admin.Models; -using Marechai.Database.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; - -namespace Marechai.Areas.Admin.Controllers -{ - [Area("Admin"), Authorize] - public class ResolutionsByGpuController : Controller - { - readonly MarechaiContext _context; - - public ResolutionsByGpuController(MarechaiContext context) => _context = context; - - // GET: ResolutionsByGpu - public async Task Index() - { - IIncludableQueryable marechaiContext = - _context.ResolutionsByGpu.Include(r => r.Gpu).Include(r => r.Resolution); - - return View(await marechaiContext.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). - Select(r => new ResolutionsByGpuViewModel - { - Gpu = r.Gpu.Name, GpuCompany = r.Gpu.Company.Name, Id = r.Id, - Resolution = r.Resolution - }).ToListAsync()); - } - - // GET: ResolutionsByGpu/Details/5 - public async Task 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 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 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 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 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 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) => _context.ResolutionsByGpu.Any(e => e.Id == id); - - [AcceptVerbs("Get", "Post")] - public async Task VerifyUnique(int gpuId, int resolutionId) => - await _context.ResolutionsByGpu.FirstOrDefaultAsync(i => i.GpuId == gpuId && i.ResolutionId == resolutionId) - is null ? Json(true) : Json("The selected GPU already has the selected resolution."); - } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Controllers/ResolutionsByScreenController.cs b/Marechai/Areas/Admin/Controllers/ResolutionsByScreenController.cs deleted file mode 100644 index a2275542..00000000 --- a/Marechai/Areas/Admin/Controllers/ResolutionsByScreenController.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Marechai.Database.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; - -namespace Marechai.Areas.Admin.Controllers -{ - [Area("Admin"), Authorize] - public class ResolutionsByScreenController : Controller - { - readonly MarechaiContext _context; - - public ResolutionsByScreenController(MarechaiContext context) => _context = context; - - // GET: ResolutionsByScreen - public async Task Index() - { - IIncludableQueryable marechaiContext = - _context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen); - - return View(await marechaiContext.OrderBy(r => r.Screen.ToString()).ThenBy(r => r.Resolution.ToString()). - ToListAsync()); - } - - // GET: ResolutionsByScreen/Details/5 - public async Task Details(long? id) - { - if(id == null) - return NotFound(); - - ResolutionsByScreen resolutionsByScreen = - await _context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen). - FirstOrDefaultAsync(m => m.Id == id); - - if(resolutionsByScreen == null) - return NotFound(); - - return View(resolutionsByScreen); - } - - // GET: ResolutionsByScreen/Create - public IActionResult Create() - { - ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new - { - r.Id, Name = r.ToString() - }).OrderBy(r => r.Name), "Id", "Name"); - - ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new - { - s.Id, - Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}" - : $"{s.Diagonal}\" {s.Type}" - }).OrderBy(s => s.Name), "Id", "Name"); - - return View(); - } - - // POST: ResolutionsByScreen/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 Create( - [Bind("ScreenId,ResolutionId,Id")] ResolutionsByScreen resolutionsByScreen) - { - if(ModelState.IsValid) - { - _context.Add(resolutionsByScreen); - await _context.SaveChangesAsync(); - - return RedirectToAction(nameof(Index)); - } - - ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new - { - r.Id, Name = r.ToString() - }).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId); - - ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new - { - s.Id, - Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}" - : $"{s.Diagonal}\" {s.Type}" - }).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId); - - return View(resolutionsByScreen); - } - - // GET: ResolutionsByScreen/Edit/5 - public async Task Edit(long? id) - { - if(id == null) - return NotFound(); - - ResolutionsByScreen resolutionsByScreen = await _context.ResolutionsByScreen.FindAsync(id); - - if(resolutionsByScreen == null) - return NotFound(); - - ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new - { - r.Id, Name = r.ToString() - }).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId); - - ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new - { - s.Id, - Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}" - : $"{s.Diagonal}\" {s.Type}" - }).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId); - - return View(resolutionsByScreen); - } - - // POST: ResolutionsByScreen/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 Edit( - long id, [Bind("ScreenId,ResolutionId,Id")] ResolutionsByScreen resolutionsByScreen) - { - if(id != resolutionsByScreen.Id) - return NotFound(); - - if(ModelState.IsValid) - { - try - { - _context.Update(resolutionsByScreen); - await _context.SaveChangesAsync(); - } - catch(DbUpdateConcurrencyException) - { - if(!ResolutionsByScreenExists(resolutionsByScreen.Id)) - return NotFound(); - - throw; - } - - return RedirectToAction(nameof(Index)); - } - - ViewData["ResolutionId"] = new SelectList(_context.Resolutions.Select(r => new - { - r.Id, Name = r.ToString() - }).OrderBy(r => r.Name), "Id", "Name", resolutionsByScreen.ResolutionId); - - ViewData["ScreenId"] = new SelectList(_context.Screens.Select(s => new - { - s.Id, - Name = s.NativeResolution != null ? $"{s.Diagonal}\" {s.Type} with {s.NativeResolution}" - : $"{s.Diagonal}\" {s.Type}" - }).OrderBy(s => s.Name), "Id", "Name", resolutionsByScreen.ScreenId); - - return View(resolutionsByScreen); - } - - // GET: ResolutionsByScreen/Delete/5 - public async Task Delete(long? id) - { - if(id == null) - return NotFound(); - - ResolutionsByScreen resolutionsByScreen = - await _context.ResolutionsByScreen.Include(r => r.Resolution).Include(r => r.Screen). - FirstOrDefaultAsync(m => m.Id == id); - - if(resolutionsByScreen == null) - return NotFound(); - - return View(resolutionsByScreen); - } - - // POST: ResolutionsByScreen/Delete/5 - [HttpPost, ActionName("Delete"), ValidateAntiForgeryToken] - public async Task DeleteConfirmed(long id) - { - ResolutionsByScreen resolutionsByScreen = await _context.ResolutionsByScreen.FindAsync(id); - _context.ResolutionsByScreen.Remove(resolutionsByScreen); - await _context.SaveChangesAsync(); - - return RedirectToAction(nameof(Index)); - } - - bool ResolutionsByScreenExists(long id) => _context.ResolutionsByScreen.Any(e => e.Id == id); - - [AcceptVerbs("Get", "Post")] - public async Task VerifyUnique(int screenId, int resolutionId) => - await _context.ResolutionsByScreen.FirstOrDefaultAsync(i => i.ScreenId == screenId && - i.ResolutionId == resolutionId) is null - ? Json(true) : Json("The selected screen already has the selected resolution."); - } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Controllers/ResolutionsController.cs b/Marechai/Areas/Admin/Controllers/ResolutionsController.cs deleted file mode 100644 index ba3ac9aa..00000000 --- a/Marechai/Areas/Admin/Controllers/ResolutionsController.cs +++ /dev/null @@ -1,159 +0,0 @@ -/****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : ResolutionsController.cs -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Resolutions admin controller -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ - -using System.Linq; -using System.Threading.Tasks; -using Marechai.Database.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; - -namespace Marechai.Areas.Admin.Controllers -{ - [Area("Admin"), Authorize] - public class ResolutionsController : Controller - { - readonly MarechaiContext _context; - - public ResolutionsController(MarechaiContext context) => _context = context; - - // GET: Admin/Resolutions - public async Task Index() => - View(await _context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height). - ThenBy(r => r.Colors).ThenBy(r => r.Grayscale).ToListAsync()); - - // GET: Admin/Resolutions/Details/5 - public async Task Details(int? id) - { - if(id == null) - return NotFound(); - - Resolution resolution = await _context.Resolutions.FirstOrDefaultAsync(m => m.Id == id); - - if(resolution == null) - return NotFound(); - - return View(resolution); - } - - // GET: Admin/Resolutions/Create - public IActionResult Create() => View(); - - // POST: Admin/Resolutions/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 Create([Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")] - Resolution resolution) - { - if(ModelState.IsValid) - { - _context.Add(resolution); - await _context.SaveChangesAsync(); - - return RedirectToAction(nameof(Index)); - } - - return View(resolution); - } - - // GET: Admin/Resolutions/Edit/5 - public async Task Edit(int? id) - { - if(id == null) - return NotFound(); - - Resolution resolution = await _context.Resolutions.FindAsync(id); - - if(resolution == null) - return NotFound(); - - return View(resolution); - } - - // POST: Admin/Resolutions/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 Edit(int id, [Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")] - Resolution resolution) - { - if(id != resolution.Id) - return NotFound(); - - if(ModelState.IsValid) - { - try - { - _context.Update(resolution); - await _context.SaveChangesAsync(); - } - catch(DbUpdateConcurrencyException) - { - if(!ResolutionExists(resolution.Id)) - return NotFound(); - - throw; - } - - return RedirectToAction(nameof(Index)); - } - - return View(resolution); - } - - // GET: Admin/Resolutions/Delete/5 - public async Task Delete(int? id) - { - if(id == null) - return NotFound(); - - Resolution resolution = await _context.Resolutions.FirstOrDefaultAsync(m => m.Id == id); - - if(resolution == null) - return NotFound(); - - return View(resolution); - } - - // POST: Admin/Resolutions/Delete/5 - [HttpPost, ActionName("Delete"), ValidateAntiForgeryToken] - public async Task DeleteConfirmed(int id) - { - Resolution resolution = await _context.Resolutions.FindAsync(id); - _context.Resolutions.Remove(resolution); - await _context.SaveChangesAsync(); - - return RedirectToAction(nameof(Index)); - } - - bool ResolutionExists(int id) => _context.Resolutions.Any(e => e.Id == id); - } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/Resolutions/Create.cshtml b/Marechai/Areas/Admin/Views/Resolutions/Create.cshtml deleted file mode 100644 index f095b508..00000000 --- a/Marechai/Areas/Admin/Views/Resolutions/Create.cshtml +++ /dev/null @@ -1,99 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Create.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view create -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ -} -@model Marechai.Database.Models.Resolution - -@{ - ViewData["Title"] = "Create"; -} -

Create

-

Resolution

-
-
-
-
-
-
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
-
- -
-
-
-
- -
-
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/Resolutions/Delete.cshtml b/Marechai/Areas/Admin/Views/Resolutions/Delete.cshtml deleted file mode 100644 index ea2d3949..00000000 --- a/Marechai/Areas/Admin/Views/Resolutions/Delete.cshtml +++ /dev/null @@ -1,87 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Delete.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view delete -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ -} -@model Marechai.Database.Models.Resolution - -@{ - ViewData["Title"] = "Delete"; -} -

Delete

-

Are you sure you want to delete this?

-
-

Resolution

-
-
-
- @Html.DisplayNameFor(model => model.Width) -
-
- @Html.DisplayFor(model => model.Width) -
-
- @Html.DisplayNameFor(model => model.Height) -
-
- @Html.DisplayFor(model => model.Height) -
-
- @Html.DisplayNameFor(model => model.Colors) -
-
- @Html.DisplayFor(model => model.Colors) -
-
- @Html.DisplayNameFor(model => model.Palette) -
-
- @Html.DisplayFor(model => model.Palette) -
-
- @Html.DisplayNameFor(model => model.Chars) -
-
- @Html.DisplayFor(model => model.Chars) -
-
- @Html.DisplayNameFor(model => model.Grayscale) -
-
- @Html.DisplayFor(model => model.Grayscale) -
-
-
- - - - Back to List - -
-
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/Resolutions/Details.cshtml b/Marechai/Areas/Admin/Views/Resolutions/Details.cshtml deleted file mode 100644 index 076d2b22..00000000 --- a/Marechai/Areas/Admin/Views/Resolutions/Details.cshtml +++ /dev/null @@ -1,87 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Details.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view details -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ -} -@model Marechai.Database.Models.Resolution - -@{ - ViewData["Title"] = "Details"; -} -

Details

-
-

Resolution

-
-
-
- @Html.DisplayNameFor(model => model.Width) -
-
- @Html.DisplayFor(model => model.Width) -
-
- @Html.DisplayNameFor(model => model.Height) -
-
- @Html.DisplayFor(model => model.Height) -
-
- @Html.DisplayNameFor(model => model.Colors) -
-
- @Html.DisplayFor(model => model.Colors) -
-
- @Html.DisplayNameFor(model => model.Palette) -
-
- @Html.DisplayFor(model => model.Palette) -
-
- @Html.DisplayNameFor(model => model.Chars) -
-
- @Html.DisplayFor(model => model.Chars) -
-
- @Html.DisplayNameFor(model => model.Grayscale) -
-
- @Html.DisplayFor(model => model.Grayscale) -
-
-
- \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/Resolutions/Edit.cshtml b/Marechai/Areas/Admin/Views/Resolutions/Edit.cshtml deleted file mode 100644 index 78d419ce..00000000 --- a/Marechai/Areas/Admin/Views/Resolutions/Edit.cshtml +++ /dev/null @@ -1,100 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Edit.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view edit -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ -} -@model Marechai.Database.Models.Resolution - -@{ - ViewData["Title"] = "Edit"; -} -

Edit

-

Resolution

-
-
-
-
-
-
- -
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
-
- -
-
-
-
- -
-
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/Resolutions/Index.cshtml b/Marechai/Areas/Admin/Views/Resolutions/Index.cshtml deleted file mode 100644 index 43df4353..00000000 --- a/Marechai/Areas/Admin/Views/Resolutions/Index.cshtml +++ /dev/null @@ -1,73 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Index.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view index -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2020 Natalia Portillo -*******************************************************************************/ -} -@model IEnumerable - -@{ - ViewData["Title"] = "Resolutions (Admin)"; -} -

Resolutions

-

- - Create new - -

- - - - - - - - - @foreach (var item in Model) - { - - - - - } - -
- Resolution -
- @item.ToString() - - - Details - - - Edit - - - Delete - -
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml deleted file mode 100644 index adba9c78..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Create.cshtml +++ /dev/null @@ -1,38 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByGpu - -@{ - ViewData["Title"] = "Create"; -} -

Create

-

Resolutions by GPU

-
-
-
-
-
-
-
- - - - -
-
- - - - -
- -
-
-
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml deleted file mode 100644 index ebc32d3f..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Delete.cshtml +++ /dev/null @@ -1,32 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByGpu - -@{ - ViewData["Title"] = "Delete"; -} -

Delete

-

Are you sure you want to delete this?

-
-

Resolution by GPU

-
-
-
- @Html.DisplayNameFor(model => model.Gpu) -
-
- @Html.DisplayFor(model => model.Gpu.Name) -
-
- @Html.DisplayNameFor(model => model.Resolution) -
-
- @Model.Resolution.ToString() -
-
-
- - - - Back to List - -
-
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml deleted file mode 100644 index bf47e0b7..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Details.cshtml +++ /dev/null @@ -1,32 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByGpu - -@{ - ViewData["Title"] = "Details"; -} -

Details

-
-

Resolution by GPU

-
-
-
- @Html.DisplayNameFor(model => model.Gpu) -
-
- @Html.DisplayFor(model => model.Gpu.Name) -
-
- @Html.DisplayNameFor(model => model.Resolution) -
-
- @Model.Resolution.ToString() -
-
-
- \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml deleted file mode 100644 index cd49cfce..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Edit.cshtml +++ /dev/null @@ -1,39 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByGpu - -@{ - ViewData["Title"] = "Edit"; -} -

Edit

-

Resolution by GPU

-
-
-
-
-
-
-
- - - - -
-
- - - - -
- - -
-
-
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml deleted file mode 100644 index ec276fe2..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByGpu/Index.cshtml +++ /dev/null @@ -1,49 +0,0 @@ -@model IEnumerable - -@{ - ViewData["Title"] = "Index"; -} -

Resolutions by GPU

-

- - Create new - -

- - - - - - - - - - @foreach (var item in Model) - { - - - - - - } - -
- @Html.DisplayNameFor(model => model.Gpu) - - @Html.DisplayNameFor(model => model.Resolution) -
- @Html.DisplayFor(modelItem => item.GpuCompany) - @Html.DisplayFor(modelItem => item.Gpu) - - @item.Resolution - - - Details - - - Edit - - - Delete - -
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Create.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByScreen/Create.cshtml deleted file mode 100644 index f713984a..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Create.cshtml +++ /dev/null @@ -1,42 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByScreen - -@{ - ViewData["Title"] = "Create"; -} -

Create

-

Resolutions by screen

-
-
-
-
-
-
-
- - - - -
-
- - - - -
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Delete.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByScreen/Delete.cshtml deleted file mode 100644 index 13fc6d66..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Delete.cshtml +++ /dev/null @@ -1,39 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByScreen - -@{ - ViewData["Title"] = "Delete"; -} -

Delete

-

Are you sure you want to delete this?

-
-

Resolutions by screen

-
-
-
- @Html.DisplayNameFor(model => model.Screen) -
-
- @if (Model.Screen.NativeResolution != null) - { - @($"{Model.Screen.Diagonal}\" {Model.Screen.Type} with {Model.Screen.NativeResolution}") - } - else - { - @($"{Model.Screen.Diagonal}\" {Model.Screen.Type}") - } -
-
- @Html.DisplayNameFor(model => model.Resolution) -
-
- @Model.Resolution.ToString() -
-
-
- - - - Back to List - -
-
\ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Details.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByScreen/Details.cshtml deleted file mode 100644 index df72f1ef..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Details.cshtml +++ /dev/null @@ -1,39 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByScreen - -@{ - ViewData["Title"] = "Details"; -} -

Details

-
-

Resolutions by screen

-
-
-
- @Html.DisplayNameFor(model => model.Screen) -
-
- @if (Model.Screen.NativeResolution != null) - { - @($"{Model.Screen.Diagonal}\" {Model.Screen.Type} with {Model.Screen.NativeResolution}") - } - else - { - @($"{Model.Screen.Diagonal}\" {Model.Screen.Type}") - } -
-
- @Html.DisplayNameFor(model => model.Resolution) -
-
- @Model.Resolution.ToString() -
-
-
- \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Edit.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByScreen/Edit.cshtml deleted file mode 100644 index fc96693a..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Edit.cshtml +++ /dev/null @@ -1,41 +0,0 @@ -@model Marechai.Database.Models.ResolutionsByScreen - -@{ - ViewData["Title"] = "Edit"; -} -

Edit

-

Resolutions by screen

-
-
-
-
-
-
-
- - - - -
-
- - - - -
- -
- - Back to List -
-
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Index.cshtml b/Marechai/Areas/Admin/Views/ResolutionsByScreen/Index.cshtml deleted file mode 100644 index 6e0535c3..00000000 --- a/Marechai/Areas/Admin/Views/ResolutionsByScreen/Index.cshtml +++ /dev/null @@ -1,55 +0,0 @@ -@model IEnumerable - -@{ - ViewData["Title"] = "Index"; -} -

Resolutions by screen

-

- - Create new - -

- - - - - - - - - - @foreach (var item in Model) - { - - - - - - } - -
- @Html.DisplayNameFor(model => model.Screen) - - @Html.DisplayNameFor(model => model.Resolution) -
- @if (item.Screen.NativeResolution != null) - { - @($"{item.Screen.Diagonal}\" {item.Screen.Type} with {item.Screen.NativeResolution}") - } - else - { - @($"{item.Screen.Diagonal}\" {item.Screen.Type}") - } - - @item.Resolution.ToString() - - - Details - - - Edit - - - Delete - -
\ No newline at end of file diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 40d3450f..b42815e7 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1399 + 3.0.99.1404 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website @@ -122,6 +122,12 @@ true + + true + + + true + <_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" /> @@ -179,5 +185,20 @@ <_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Details.cshtml" /> <_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Edit.cshtml" /> <_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Index.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Create.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Delete.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Details.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Edit.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\Resolutions\Index.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Create.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Delete.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Details.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Edit.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByGpu\Index.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Create.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Delete.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Details.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Edit.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Admin\Views\ResolutionsByScreen\Index.cshtml" /> \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Gpu.razor b/Marechai/Pages/Admin/Details/Gpu.razor index b3537644..f42fe19d 100644 --- a/Marechai/Pages/Admin/Details/Gpu.razor +++ b/Marechai/Pages/Admin/Details/Gpu.razor @@ -37,6 +37,8 @@ @inject IStringLocalizer L @inject CompaniesService CompaniesService @inject NavigationManager NavigationManager +@inject ResolutionsService ResolutionsService +@inject ResolutionsByGpuService ResolutionsByGpuService @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Graphical processing unit details"]


@@ -239,4 +241,104 @@ } @L["Back to list"] - \ No newline at end of file + +@if (!_editing) +{ +
+

@L["Resolutions supported by this graphical processing unit"]

+ + @if (_addingResolution) + { +
+ + @L["Resolutions"] + + + + +
+ } + @if (_gpuResolutions?.Count > 0) + { +
+ + + + + + + + + + + + + + @foreach (var item in _gpuResolutions) + { + + + + + + + + + + } + +
+ @L["Width"] + + @L["Height"] + + @L["Colors"] + + @L["Palette"] + + @L["Chars"] + + @L["Grayscale"] +
+ @item.Resolution.Width + + @item.Resolution.Height + + @item.Resolution.Colors + + @item.Resolution.Palette + + @item.Resolution.Chars + + @item.Resolution.Grayscale + + +
+
+ } + + + + + + @_deleteTitle + + + + @_deleteText + + + + + + + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Gpu.razor.cs b/Marechai/Pages/Admin/Details/Gpu.razor.cs index 235960a6..e4e46566 100644 --- a/Marechai/Pages/Admin/Details/Gpu.razor.cs +++ b/Marechai/Pages/Admin/Details/Gpu.razor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Blazorise; using Marechai.Shared; @@ -10,20 +11,30 @@ namespace Marechai.Pages.Admin.Details { public partial class Gpu { - List _companies; - bool _creating; - bool _editing; - bool _loaded; - GpuViewModel _model; - bool _prototype; - bool _unknownCompany; - bool _unknownDieSize; - bool _unknownIntroduced; - bool _unknownModelCode; - bool _unknownPackage; - bool _unknownProcess; - bool _unknownProcessNm; - bool _unknownTransistors; + bool _addingResolution; + int? _addingResolutionId; + List _companies; + bool _creating; + ResolutionByGpuViewModel _currentResolution; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _editing; + Modal _frmDelete; + List _gpuResolutions; + bool _loaded; + GpuViewModel _model; + bool _prototype; + List _resolutions; + bool _savingResolution; + bool _unknownCompany; + bool _unknownDieSize; + bool _unknownIntroduced; + bool _unknownModelCode; + bool _unknownPackage; + bool _unknownProcess; + bool _unknownProcessNm; + bool _unknownTransistors; [Parameter] public int Id { get; set; } @@ -41,8 +52,10 @@ namespace Marechai.Pages.Admin.Details !_creating) return; - _companies = await CompaniesService.GetAsync(); - _model = _creating ? new GpuViewModel() : await Service.GetAsync(Id); + _companies = await CompaniesService.GetAsync(); + _model = _creating ? new GpuViewModel() : await Service.GetAsync(Id); + _resolutions = await ResolutionsService.GetAsync(); + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/gpus/edit/", StringComparison.InvariantCulture); @@ -162,5 +175,91 @@ namespace Marechai.Pages.Admin.Details void ValidateProcess(ValidatorEventArgs e) => Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); + + void ShowResolutionDeleteModal(long itemId) + { + _currentResolution = _gpuResolutions.FirstOrDefault(n => n.Id == itemId); + _deleteTitle = L["Delete resolution from this graphical processing unit"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the resolution {0} from this graphical processing unit?"], + _currentResolution); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentResolution is null) + return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id); + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _currentResolution = null; + } + + void OnAddResolutionClick() + { + _addingResolution = true; + _savingResolution = false; + _addingResolutionId = _resolutions.First().Id; + } + + void CancelAddResolution() + { + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + } + + async Task ConfirmAddResolution() + { + if(_addingResolutionId is null || + _addingResolutionId <= 0) + { + CancelAddResolution(); + + return; + } + + _savingResolution = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, Id); + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); + + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Resolution.razor b/Marechai/Pages/Admin/Details/Resolution.razor new file mode 100644 index 00000000..b104cf1d --- /dev/null +++ b/Marechai/Pages/Admin/Details/Resolution.razor @@ -0,0 +1,131 @@ +@{ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// ---------------------------------------------------------------------------- +// +// Filename : Details.cshtml +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Admin view details +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2020 Natalia Portillo +*******************************************************************************/ +} + +@page "/admin/resolutions/details/{Id:int}" +@page "/admin/resolutions/edit/{Id:int}" +@page "/admin/resolutions/create" +@inherits OwningComponentBase +@inject IStringLocalizer L +@inject NavigationManager NavigationManager +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

@L["Resolution details"]

+
+ +@if (!_loaded) +{ +

@L["Loading..."]

+ + return; +} + +
+ + @L["Width (pixels or characters)"] + + + + @L["Please enter a valid width in pixels or characters."] + + + + + + @L["Height (pixels or characters)"] + + + + @L["Please enter a valid height in pixels or characters."] + + + + + @if (_editing || _model.Colors.HasValue) + { + + @L["Colors"] + @if (_editing) + { + @L["Unknown (colors)"] + } + @if (!_editing || + !_unknownColors) + { + + + + @L["Please enter a valid number of colors."] + + + + } + + } + @if (_editing || _model.Palette.HasValue) + { + + @L["Colors in palette"] + @if (_editing) + { + @L["Unknown (colors in palette)"] + } + @if (!_editing || + !_unknownPalette) + { + + + + @L["Please enter a valid number of colors in palette."] + + + + } + + } + + @L["Resolution is character based (text only)."] + + + @L["Resolution only has gray colors."] + +
+
+ @if (!_editing) + { + + } + else + { + + + } + @L["Back to list"] +
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Resolution.razor.cs b/Marechai/Pages/Admin/Details/Resolution.razor.cs new file mode 100644 index 00000000..a22b468f --- /dev/null +++ b/Marechai/Pages/Admin/Details/Resolution.razor.cs @@ -0,0 +1,104 @@ +using System; +using System.Threading.Tasks; +using Blazorise; +using Marechai.Shared; +using Marechai.ViewModels; +using Microsoft.AspNetCore.Components; + +namespace Marechai.Pages.Admin.Details +{ + public partial class Resolution + { + bool _creating; + bool _editing; + bool _loaded; + ResolutionViewModel _model; + bool _unknownColors; + bool _unknownPalette; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) + return; + + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). + StartsWith("admin/resolutions/create", StringComparison.InvariantCulture); + + if(Id <= 0 && + !_creating) + return; + + _model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id); + + _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). + StartsWith("admin/resolutions/edit/", + StringComparison.InvariantCulture); + + if(_editing) + SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownColors = !_model.Colors.HasValue; + _unknownPalette = !_model.Colors.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/resolutions"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownColors) + _model.Colors = null; + else if(_model.Colors <= 0) + return; + + if(_unknownPalette) + _model.Palette = null; + else if(_model.Palette <= 0) + return; + + if(_creating) + Id = await Service.CreateAsync(_model); + else + await Service.UpdateAsync(_model); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); + } +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Screen.razor b/Marechai/Pages/Admin/Details/Screen.razor index bd385e66..602612c8 100644 --- a/Marechai/Pages/Admin/Details/Screen.razor +++ b/Marechai/Pages/Admin/Details/Screen.razor @@ -37,6 +37,8 @@ @inject IStringLocalizer L @inject ResolutionsService ResolutionsService @inject NavigationManager NavigationManager +@inject ResolutionsByScreenService ResolutionsByScreenService + @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Screen details"]


@@ -89,7 +91,6 @@ } - } @@ -165,4 +166,105 @@ } @L["Back to list"] - \ No newline at end of file + +@if (!_editing) +{ +
+

@L["Resolutions supported by this screen"]

+ + @if (_addingResolution) + { +
+ + @L["Resolutions"] + + + + +
+ } + @if (_screenResolutions?.Count > 0) + { +
+ + + + + + + + + + + + + + @foreach (var item in _screenResolutions) + { + + + + + + + + + + } + +
+ @L["Width"] + + @L["Height"] + + @L["Colors"] + + @L["Palette"] + + @L["Chars"] + + @L["Grayscale"] +
+ @item.Resolution.Width + + @item.Resolution.Height + + @item.Resolution.Colors + + @item.Resolution.Palette + + @item.Resolution.Chars + + @item.Resolution.Grayscale + + +
+
+ } + + + + + + @_deleteTitle + + + + @_deleteText + + + + + + + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Screen.razor.cs b/Marechai/Pages/Admin/Details/Screen.razor.cs index 08676cb0..af4ad2a3 100644 --- a/Marechai/Pages/Admin/Details/Screen.razor.cs +++ b/Marechai/Pages/Admin/Details/Screen.razor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Blazorise; using Marechai.Shared; @@ -10,15 +11,24 @@ namespace Marechai.Pages.Admin.Details { public partial class Screen { - bool _creating; - bool _editing; - bool _loaded; - ScreenViewModel _model; - List _resolutions; - bool _unknownColors; - bool _unknownHeight; - bool _unknownType; - bool _unknownWidth; + bool _addingResolution; + int? _addingResolutionId; + bool _creating; + ResolutionByScreenViewModel _currentResolution; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _editing; + Modal _frmDelete; + bool _loaded; + ScreenViewModel _model; + List _resolutions; + bool _savingResolution; + List _screenResolutions; + bool _unknownColors; + bool _unknownHeight; + bool _unknownType; + bool _unknownWidth; [Parameter] public int Id { get; set; } @@ -36,8 +46,9 @@ namespace Marechai.Pages.Admin.Details !_creating) return; - _resolutions = await ResolutionsService.GetAsync(); - _model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id); + _resolutions = await ResolutionsService.GetAsync(); + _model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id); + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/screens/edit/", @@ -120,5 +131,90 @@ namespace Marechai.Pages.Admin.Details void ValidateType(ValidatorEventArgs e) => Validators.ValidateString(e, L["Screen type cannot be bigger than 256 characters."], 256); + + void ShowResolutionDeleteModal(long itemId) + { + _currentResolution = _screenResolutions.FirstOrDefault(n => n.Id == itemId); + _deleteTitle = L["Delete resolution from this screen"]; + + _deleteText = string.Format(L["Are you sure you want to delete the resolution {0} from this screen?"], + _currentResolution); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentResolution is null) + return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id); + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _currentResolution = null; + } + + void OnAddResolutionClick() + { + _addingResolution = true; + _savingResolution = false; + _addingResolutionId = _resolutions.First().Id; + } + + void CancelAddResolution() + { + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + } + + async Task ConfirmAddResolution() + { + if(_addingResolutionId is null || + _addingResolutionId <= 0) + { + CancelAddResolution(); + + return; + } + + _savingResolution = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id); + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); + + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Index.razor b/Marechai/Pages/Admin/Index.razor index bb6908a5..762f4afa 100644 --- a/Marechai/Pages/Admin/Index.razor +++ b/Marechai/Pages/Admin/Index.razor @@ -80,6 +80,9 @@
  • @L["Sound synthesizers"]
  • +
  • + @L["Resolutions"] +
  • diff --git a/Marechai/Pages/Admin/Resolutions.razor b/Marechai/Pages/Admin/Resolutions.razor new file mode 100644 index 00000000..61ef84db --- /dev/null +++ b/Marechai/Pages/Admin/Resolutions.razor @@ -0,0 +1,118 @@ +@{ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// ---------------------------------------------------------------------------- +// +// Filename : Resolutions.razor +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// List of resolutions +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2020 Natalia Portillo +*******************************************************************************/ +} + +@page "/admin/resolutions" +@inherits OwningComponentBase +@inject IStringLocalizer L +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

    @L["Resolutions"]

    +@if (_resolutions is null) +{ +

    @L["Loading..."]

    + + return; +} +

    + @L["Create new"] +

    + + + + + + + + + + + + + + @foreach (var item in _resolutions) + { + + + + + + + + + + } + +
    + @L["Width"] + + @L["Height"] + + @L["Colors"] + + @L["Palette"] + + @L["Chars"] + + @L["Grayscale"] +
    + @item.Width + + @item.Height + + @item.Colors + + @item.Palette + + @item.Chars + + @item.Grayscale + + @L["Details"] + @L["Edit"] + +
    + + + + + + @L["Delete resolution"] + + + + @string.Format(L["Are you sure you want to delete resolution {0}?"], _resolution) + + + + + + + diff --git a/Marechai/Pages/Admin/Resolutions.razor.cs b/Marechai/Pages/Admin/Resolutions.razor.cs new file mode 100644 index 00000000..c0a80d87 --- /dev/null +++ b/Marechai/Pages/Admin/Resolutions.razor.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Blazorise; +using Marechai.ViewModels; + +namespace Marechai.Pages.Admin +{ + public partial class Resolutions + { + bool _deleteInProgress; + Modal _frmDelete; + ResolutionViewModel _resolution; + List _resolutions; + + void ShowModal(int itemId) + { + _resolution = _resolutions.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_resolution is null) + return; + + _deleteInProgress = true; + _resolutions = null; + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_resolution.Id); + _resolutions = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _resolution = null; + + protected override async Task OnInitializedAsync() => _resolutions = await Service.GetAsync(); + } +} \ No newline at end of file diff --git a/Marechai/Resources/Services/AdminService.es.resx b/Marechai/Resources/Services/AdminService.es.resx index 31cca8f1..9ff4c208 100644 --- a/Marechai/Resources/Services/AdminService.es.resx +++ b/Marechai/Resources/Services/AdminService.es.resx @@ -206,4 +206,8 @@ Sintetizadores de sonido Sound synthesizers. + + Resoluciones + Resolutions. + \ No newline at end of file diff --git a/Marechai/Resources/Services/GpusService.en.resx b/Marechai/Resources/Services/GpusService.en.resx index 42f4ebe8..9ee798f0 100644 --- a/Marechai/Resources/Services/GpusService.en.resx +++ b/Marechai/Resources/Services/GpusService.en.resx @@ -150,4 +150,8 @@ Unknown Unknown, referring to the number of transistors + + Add new + Add new, referring to resolutions supported by this gpu + \ No newline at end of file diff --git a/Marechai/Resources/Services/GpusService.es.resx b/Marechai/Resources/Services/GpusService.es.resx index f277b6c4..01086a55 100644 --- a/Marechai/Resources/Services/GpusService.es.resx +++ b/Marechai/Resources/Services/GpusService.es.resx @@ -270,4 +270,52 @@ Por favor introduce un número válido de transistores. Please enter a valid number of transistors. + + Añadir nueva + Add new, referring to resolutions supported by this gpu + + + Prototipo + Resolutions supported by this graphical processing unit + + + Resoluciones + Resolutions + + + Añadir + Add + + + Ancho + Width + + + Alto + Height + + + Colores + Colors + + + Paleta + Palette + + + Caracteres + Chars + + + Escala de grises + Grayscale + + + Eliminar resolución de esta unidad de proceso de gráficos + Delete resolution from this graphical processing unit + + + ¿Estás seguro de eliminar la resolución {0} de esta unidad de proceso de gráficos? + Are you sure you want to delete the resolution {0} from this graphical processing unit? + \ No newline at end of file diff --git a/Marechai/Resources/Services/ResolutionsService.en.resx b/Marechai/Resources/Services/ResolutionsService.en.resx new file mode 100644 index 00000000..27b09ec2 --- /dev/null +++ b/Marechai/Resources/Services/ResolutionsService.en.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Unknown + Unknown, referring to colors in resolution + + + Unknown + Unknown, referring to colors in palette resolution + + \ No newline at end of file diff --git a/Marechai/Resources/Services/ResolutionsService.es.resx b/Marechai/Resources/Services/ResolutionsService.es.resx new file mode 100644 index 00000000..2fe906b2 --- /dev/null +++ b/Marechai/Resources/Services/ResolutionsService.es.resx @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Desconocidos + Unknown, referring to colors in resolution + + + Desconocidos + Unknown, referring to colors in palette resolution + + + Resoluciones + Resolutions + + + Crear nueva + Create new + + + Ancho + Width + + + Alto + Height + + + Colores + Colors + + + Paleta + Palette + + + Caracteres + Chars + + + Escala de grises + Grayscale + + + Detalles + Details + + + Editar + Edit + + + Eliminar + Delete + + + Eliminar resolución + Delete resolution + + + ¿Estás seguro de eliminar la resolución {0}? + Are you sure you want to delete resolution {0}? + + + Detalles de resolución + Resolution details + + + Cargando... + Loading... + + + Ancho (píxeles o caracteres) + Width (pixels or characters) + + + Por favor introduce un ancho válido en píxeles o caracteres. + Please enter a valid width in pixels or characters. + + + Alto (píxeles o caracteres) + Height (pixels or characters) + + + Por favor introduce un alto válido en píxeles o caracteres. + Please enter a valid height in pixels or characters. + + + Por favor introduce un número de colores válido. + Please enter a valid number of colors. + + + Colores en paleta + Colors in palette + + + Por favor introduce un número de colores en paleta válido. + Please enter a valid number of colors in palette. + + + La resolución es basada en caracteres (sólo texto). + Resolution is character based (text only). + + + La resolución sólo tiene grises. + Resolution only has gray colors. + + + Guardar + Save + + + Cancelar + Cancel + + + Volver a la lista + Back to list + + \ No newline at end of file diff --git a/Marechai/Resources/Services/ScreensService.en.resx b/Marechai/Resources/Services/ScreensService.en.resx index a976b945..4df8e5c3 100644 --- a/Marechai/Resources/Services/ScreensService.en.resx +++ b/Marechai/Resources/Services/ScreensService.en.resx @@ -134,4 +134,8 @@ Unknown Unknown, referring to a screen type + + Add new + Add new, referring to resolutions supported by this screen + \ No newline at end of file diff --git a/Marechai/Resources/Services/ScreensService.es.resx b/Marechai/Resources/Services/ScreensService.es.resx index dc29872e..12274f4d 100644 --- a/Marechai/Resources/Services/ScreensService.es.resx +++ b/Marechai/Resources/Services/ScreensService.es.resx @@ -238,4 +238,52 @@ El tipo de pantalla no puede tener más de 256 caracteres. Screen type cannot be bigger than 256 characters. + + Añadir nueva + Add new, referring to resolutions supported by this screen + + + Resoluciones soportadas por esta pantalla + Resolutions supported by this screen + + + Resoluciones + Resolutions + + + Añadir + Add + + + Ancho + Width + + + Alto + Height + + + Colores + Colors + + + Paleta + Palette + + + Caracteres + Chars + + + Escala de grises + Grayscale + + + Eliminar resolución de esta pantalla + Delete resolution from this screen + + + ¿Estás seguro de eliminar la resolución {0} de esta pantalla? + Are you sure you want to delete the resolution {0} from this screen? + \ No newline at end of file diff --git a/Marechai/Services/Register.cs b/Marechai/Services/Register.cs index 8229ddc4..3f21a2b5 100644 --- a/Marechai/Services/Register.cs +++ b/Marechai/Services/Register.cs @@ -68,6 +68,9 @@ namespace Marechai.Services services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } } } \ No newline at end of file diff --git a/Marechai/Services/ResolutionsByGpuService.cs b/Marechai/Services/ResolutionsByGpuService.cs new file mode 100644 index 00000000..83ecbdf1 --- /dev/null +++ b/Marechai/Services/ResolutionsByGpuService.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Database.Models; +using Marechai.ViewModels; +using Microsoft.EntityFrameworkCore; + +namespace Marechai.Services +{ + public class ResolutionsByGpuService + { + readonly MarechaiContext _context; + + public ResolutionsByGpuService(MarechaiContext context) => _context = context; + + public async Task> GetByGpu(int resolutionId) => + await _context.ResolutionsByGpu.Where(r => r.ResolutionId == resolutionId). + Select(r => new ResolutionByGpuViewModel + { + Id = r.Id, GpuId = r.GpuId, Resolution = new ResolutionViewModel + { + Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height, + Colors = r.Resolution.Colors, Palette = r.Resolution.Palette, + Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale + }, + ResolutionId = r.ResolutionId + }).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height). + ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale). + ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync(); + + public async Task DeleteAsync(long id) + { + ResolutionsByGpu item = await _context.ResolutionsByGpu.FindAsync(id); + + if(item is null) + return; + + _context.ResolutionsByGpu.Remove(item); + + await _context.SaveChangesAsync(); + } + + public async Task CreateAsync(int resolutionId, int gpuId) + { + var item = new ResolutionsByGpu + { + GpuId = gpuId, ResolutionId = resolutionId + }; + + await _context.ResolutionsByGpu.AddAsync(item); + await _context.SaveChangesAsync(); + + return item.Id; + } + } +} \ No newline at end of file diff --git a/Marechai/Services/ResolutionsByScreenService.cs b/Marechai/Services/ResolutionsByScreenService.cs new file mode 100644 index 00000000..47faeea6 --- /dev/null +++ b/Marechai/Services/ResolutionsByScreenService.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Database.Models; +using Marechai.ViewModels; +using Microsoft.EntityFrameworkCore; + +namespace Marechai.Services +{ + public class ResolutionsByScreenService + { + readonly MarechaiContext _context; + + public ResolutionsByScreenService(MarechaiContext context) => _context = context; + + public async Task> GetByScreen(int resolutionId) => + await _context.ResolutionsByScreen.Where(r => r.ResolutionId == resolutionId). + Select(r => new ResolutionByScreenViewModel + { + Id = r.Id, ScreenId = r.ScreenId, Resolution = new ResolutionViewModel + { + Id = r.Resolution.Id, Width = r.Resolution.Width, Height = r.Resolution.Height, + Colors = r.Resolution.Colors, Palette = r.Resolution.Palette, + Chars = r.Resolution.Chars, Grayscale = r.Resolution.Grayscale + }, + ResolutionId = r.ResolutionId + }).OrderBy(r => r.Resolution.Width).ThenBy(r => r.Resolution.Height). + ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Grayscale). + ThenBy(r => r.Resolution.Colors).ThenBy(r => r.Resolution.Palette).ToListAsync(); + + public async Task DeleteAsync(long id) + { + ResolutionsByScreen item = await _context.ResolutionsByScreen.FindAsync(id); + + if(item is null) + return; + + _context.ResolutionsByScreen.Remove(item); + + await _context.SaveChangesAsync(); + } + + public async Task CreateAsync(int resolutionId, int screenId) + { + var item = new ResolutionsByScreen + { + ScreenId = screenId, ResolutionId = resolutionId + }; + + await _context.ResolutionsByScreen.AddAsync(item); + await _context.SaveChangesAsync(); + + return item.Id; + } + } +} \ No newline at end of file diff --git a/Marechai/Services/ResolutionsService.cs b/Marechai/Services/ResolutionsService.cs index 1aa271db..99fc3b90 100644 --- a/Marechai/Services/ResolutionsService.cs +++ b/Marechai/Services/ResolutionsService.cs @@ -13,15 +13,62 @@ namespace Marechai.Services public ResolutionsService(MarechaiContext context) => _context = context; - public async Task> GetAsync() - { - List list = await _context.Resolutions.Select(r => new ResolutionViewModel + public async Task> GetAsync() => + await _context.Resolutions.Select(r => new ResolutionViewModel + { + Id = r.Id, Width = r.Width, Height = r.Height, Colors = r.Colors, + Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale + }).OrderBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Chars).ThenBy(r => r.Grayscale). + ThenBy(r => r.Colors).ThenBy(r => r.Palette).ToListAsync(); + + public async Task GetAsync(int id) => + await _context.Resolutions.Where(r => r.Id == id).Select(r => new ResolutionViewModel { Id = r.Id, Width = r.Width, Height = r.Height, Colors = r.Colors, Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale - }).ToListAsync(); + }).FirstOrDefaultAsync(); - return list.OrderBy(r => r.ToString()).ToList(); + public async Task UpdateAsync(ResolutionViewModel viewModel) + { + Resolution model = await _context.Resolutions.FindAsync(viewModel.Id); + + if(model is null) + return; + + model.Chars = viewModel.Chars; + model.Colors = viewModel.Colors; + model.Grayscale = viewModel.Grayscale; + model.Height = viewModel.Height; + model.Palette = viewModel.Palette; + model.Width = viewModel.Width; + + await _context.SaveChangesAsync(); + } + + public async Task CreateAsync(ResolutionViewModel viewModel) + { + var model = new Resolution + { + Chars = viewModel.Chars, Colors = viewModel.Colors, Grayscale = viewModel.Grayscale, + Height = viewModel.Height, Palette = viewModel.Palette, Width = viewModel.Width + }; + + await _context.Resolutions.AddAsync(model); + await _context.SaveChangesAsync(); + + return model.Id; + } + + public async Task DeleteAsync(int id) + { + Resolution item = await _context.Resolutions.FindAsync(id); + + if(item is null) + return; + + _context.Resolutions.Remove(item); + + await _context.SaveChangesAsync(); } } } \ No newline at end of file diff --git a/Marechai/ViewModels/ResolutionByGpuViewModel.cs b/Marechai/ViewModels/ResolutionByGpuViewModel.cs new file mode 100644 index 00000000..fb4639bf --- /dev/null +++ b/Marechai/ViewModels/ResolutionByGpuViewModel.cs @@ -0,0 +1,9 @@ +namespace Marechai.ViewModels +{ + public class ResolutionByGpuViewModel : BaseViewModel + { + public int ResolutionId { get; set; } + public int GpuId { get; set; } + public ResolutionViewModel Resolution { get; set; } + } +} \ No newline at end of file diff --git a/Marechai/ViewModels/ResolutionByScreenViewModel.cs b/Marechai/ViewModels/ResolutionByScreenViewModel.cs new file mode 100644 index 00000000..e43c7b8a --- /dev/null +++ b/Marechai/ViewModels/ResolutionByScreenViewModel.cs @@ -0,0 +1,9 @@ +namespace Marechai.ViewModels +{ + public class ResolutionByScreenViewModel : BaseViewModel + { + public int ResolutionId { get; set; } + public int ScreenId { get; set; } + public ResolutionViewModel Resolution { get; set; } + } +} \ No newline at end of file