Move videogame consoles search to Blazor.

This commit is contained in:
2020-05-22 03:15:06 +01:00
parent ef99e0c8e9
commit df6ad08043
13 changed files with 664 additions and 456 deletions

View File

@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Marechai/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Marechai/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=videogame/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -1,100 +0,0 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : ConsoleController.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videogame console 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System.Linq;
using Marechai.Database;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
namespace Marechai.Controllers
{
public class ConsoleController : Controller
{
readonly MarechaiContext _context;
readonly IWebHostEnvironment hostingEnvironment;
public ConsoleController(IWebHostEnvironment env, MarechaiContext context)
{
hostingEnvironment = env;
_context = context;
}
public IActionResult Index()
{
ViewBag.ItemCount = _context.Machines.Count(m => m.Type == MachineType.Console);
ViewBag.MinYear = _context.
Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
t.Introduced.Value.Year > 1000).Min(t => t.Introduced.Value.Year);
ViewBag.MaxYear = _context.
Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
t.Introduced.Value.Year > 1000).Max(t => t.Introduced.Value.Year);
return View();
}
public IActionResult ByLetter(char id)
{
// ToUpper()
if(id >= 'a' &&
id <= 'z')
id -= (char)32;
// Check if not letter
if(id < 'A' ||
id > 'Z')
id = '\0';
ViewBag.Letter = id;
return View(id == '\0' ? _context.Machines.Where(m => m.Type == MachineType.Console).ToArray() : _context.
Machines.
Where(m =>
m.
Type ==
MachineType.
Console &&
m.
Name.
StartsWith(id)).
ToArray());
}
public IActionResult ByYear(int id)
{
ViewBag.Year = id;
return View(_context.Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
t.Introduced.Value.Year == id).ToArray());
}
}
}

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.0.99.965</Version> <Version>3.0.99.966</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>

View File

@@ -42,7 +42,7 @@
<p> <p>
@L["Here you can consult our database."] @L["Here you can consult our database."]
<br /> <br />
@L["In this database you can find technical information as well as computers history, catalogued by companies, alfabetically and by release date."] @L["In this database you can find technical information as well as computers history, catalogued by companies, alphabetically and by release date."]
<br /> <br />
@string.Format(L["{0} computers actually catalogued in the database."], _computers) @string.Format(L["{0} computers actually catalogued in the database."], _computers)
</p> </p>

View File

@@ -0,0 +1,261 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Index.razor
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Consoles 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
}
@page "/consoles"
@inherits OwningComponentBase<ConsolesService>
@inject IStringLocalizer<ConsolesService> L
@if (!_loaded)
{
@L["Loading..."]
}
<p>
@L["Here you can consult our database."]
<br />
@L["In this database you can find technical information as well as videogame consoles history, catalogued by companies, alphabetically and by release date."]
<br />
@string.Format(L["{0} videogame consoles actually catalogued in the database."], _consoles)
</p>
<p>
<br>
<br>
@L["Search by companies"]
<br>
<a href="/companies/Q">
Q
</a>
<a href="/companies/W">
W
</a>
<a href="/companies/E">
E
</a>
<a href="/companies/R">
R
</a>
<a href="/companies/T">
T
</a>
<a href="/companies/Y">
Y
</a>
<a href="/companies/U">
U
</a>
<a href="/companies/I">
I
</a>
<a href="/companies/O">
O
</a>
<a href="/companies/P">
P
</a>
<br>
<a href="/companies/A">
A
</a>
<a href="/companies/S">
S
</a>
<a href="/companies/D">
D
</a>
<a href="/companies/F">
F
</a>
<a href="/companies/G">
G
</a>
<a href="/companies/H">
H
</a>
<a href="/companies/J">
J
</a>
<a href="/companies/K">
K
</a>
<a href="/companies/L">
L
</a>
<br>
<a href="/companies/Z">
Z
</a>
<a href="/companies/X">
X
</a>
<a href="/companies/C">
C
</a>
<a href="/companies/V">
V
</a>
<a href="/companies/B">
B
</a>
<a href="/companies/N">
N
</a>
<a href="/companies/M">
M
</a>
<br>
<a href="/companies">
@L["All companies"]
</a>
</p>
<p>
@L["Alphabetically search"]
<br>
<a href="/consoles/Q">
Q
</a>
<a href="/consoles/W">
W
</a>
<a href="/consoles/E">
E
</a>
<a href="/consoles/R">
R
</a>
<a href="/consoles/T">
T
</a>
<a href="/consoles/Y">
Y
</a>
<a href="/consoles/U">
U
</a>
<a href="/consoles/I">
I
</a>
<a href="/consoles/O">
O
</a>
<a href="/consoles/P">
P
</a>
<br>
<a href="/consoles/A">
A
</a>
<a href="/consoles/S">
S
</a>
<a href="/consoles/D">
D
</a>
<a href="/consoles/F">
F
</a>
<a href="/consoles/G">
G
</a>
<a href="/consoles/H">
H
</a>
<a href="/consoles/J">
J
</a>
<a href="/consoles/K">
K
</a>
<a href="/consoles/L">
L
</a>
<br>
<a href="/consoles/Z">
Z
</a>
<a href="/consoles/X">
X
</a>
<a href="/consoles/C">
C
</a>
<a href="/consoles/V">
V
</a>
<a href="/consoles/B">
B
</a>
<a href="/consoles/N">
N
</a>
<a href="/consoles/M">
M
</a>
<br>
<a href="/consoles/all">
@L["All videogame consoles"]
</a>
</p>
<p>
@L["Search by year"]
<br>
@{ var counter = 0; }
@for (int i = _minYear; i <= _maxYear; i++)
{
{
counter++;
}
<a href="/consoles/year/@i">
@i
</a>
if (counter % 8 == 0)
{
<br />
}
}
</p>
@code
{
bool _loaded;
int _consoles;
int _minYear;
int _maxYear;
protected override async Task OnInitializedAsync()
{
_consoles = await Service.GetConsolesCountAsync();
_minYear = await Service.GetMinimumYearAsync();
_maxYear = await Service.GetMaximumYearAsync();
_loaded = true;
}
}

View File

@@ -0,0 +1,124 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Search.razor
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Consoles search
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
}
@page "/consoles/all"
@page "/consoles/year/{Year:int}"
@page "/consoles/{StartingCharacter}"
@inherits OwningComponentBase<ConsolesService>
@inject IStringLocalizer<ConsolesService> L
@if (_consoles is null)
{
@L["Loading..."]
}
<p>@L["Search results:"]</p>
<p align="center">
@if (_character.HasValue)
{
<b>@string.Format(L["Videogame consoles starting with {0}"], _character)</b>
<br />
}
else if (Year.HasValue)
{
<b>@string.Format(L["Videogame consoles introduced in {0}"], Year)</b>
<br />
}
@if (_consoles?.Count > 0)
{
<p>
@string.Format(L["{0} videogame consoles found in the database."], _consoles.Count)
<br />
@foreach (var console in _consoles)
{
<a href="/machine/@console.Id">
@console.CompanyName @console.Name</a>
<br />
}
</p>
}
else
{
@if (_character.HasValue)
{
<p>@L["There are no videogame consoles found in the database that start with this letter."]</p>
}
else if (Year.HasValue)
{
<p>@L["There are no videogame consoles found introduced this year."]</p>
}
}
</p>
@code
{
[Parameter]
public int? Year { get; set; }
[Parameter]
public string StartingCharacter { get; set; }
List<MachineViewModel> _consoles;
char? _character;
protected override async Task OnInitializedAsync()
{
_character = null;
if (!string.IsNullOrWhiteSpace(StartingCharacter) &&
StartingCharacter.Length == 1)
{
_character = StartingCharacter[0];
// ToUpper()
if (_character >= 'a' &&
_character <= 'z')
_character -= (char)32;
// Check if not letter or number
if (_character < '0' ||
(_character > '9' && _character < 'A') ||
_character > 'Z')
_character = null;
}
if (_character.HasValue)
_consoles = await Service.GetConsolesByLetterAsync(_character.Value);
if (Year.HasValue &&
_consoles is null)
_consoles = await Service.GetConsolesByYearAsync(Year.Value);
_consoles ??= await Service.GetConsolesAsync();
}
}

View File

@@ -126,7 +126,7 @@
<value>Aquí puedes consultar nuestra base de datos.</value> <value>Aquí puedes consultar nuestra base de datos.</value>
<comment>Introduction to search</comment> <comment>Introduction to search</comment>
</data> </data>
<data name="In this database you can find technical information as well as computers history, catalogued by companies, alfabetically and by release date." xml:space="preserve"> <data name="In this database you can find technical information as well as computers history, catalogued by companies, alphabetically and by release date." xml:space="preserve">
<value>En esta base de datos puedes encontrar información técnica así como historia de los ordenadores, catalogados por compañía, alfabéticamente y por fecha de introducción.</value> <value>En esta base de datos puedes encontrar información técnica así como historia de los ordenadores, catalogados por compañía, alfabéticamente y por fecha de introducción.</value>
<comment>Introduction to database</comment> <comment>Introduction to database</comment>
</data> </data>

View File

@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ReSharper disable MarkupTextTypo -->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Loading..." xml:space="preserve">
<value>Cargando...</value>
<comment>Message that appears while data is being loaded from database</comment>
</data>
<data name="Here you can consult our database." xml:space="preserve">
<value>Aquí puedes consultar nuestra base de datos.</value>
<comment>Introduction to search</comment>
</data>
<data name="In this database you can find technical information as well as videogame consoles history, catalogued by companies, alphabetically and by release date." xml:space="preserve">
<value>En esta base de datos puedes encontrar información técnica así como historia de los videoconsolas, catalogados por compañía, alfabéticamente y por fecha de introducción.</value>
<comment>Introduction to database</comment>
</data>
<data name="{0} videogame consoles actually catalogued in the database." xml:space="preserve">
<value>{0} videoconsolas catalogados en la base de datos</value>
<comment>Consoles in database, {0} number</comment>
</data>
<data name="Search by companies" xml:space="preserve">
<value>Buscar por compañías</value>
<comment>Search by companies</comment>
</data>
<data name="All companies" xml:space="preserve">
<value>Todas las compañías</value>
<comment>All companies</comment>
</data>
<data name="Alphabetically search" xml:space="preserve">
<value>Búsqueda alfabética</value>
<comment>Search alphabetically</comment>
</data>
<data name="All videogame consoles" xml:space="preserve">
<value>Todas las videoconsolas</value>
<comment>All consoles</comment>
</data>
<data name="Search by year" xml:space="preserve">
<value>Búsqueda por año</value>
<comment>Search by year</comment>
</data>
<data name="Search results:" xml:space="preserve">
<value>Resultados:</value>
<comment>Search results</comment>
</data>
<data name="Videogame consoles starting with {0}" xml:space="preserve">
<value>Videoconsolas cuyo nombre comienza por {0}</value>
<comment>Consoles starting with {0}, a letter</comment>
</data>
<data name="Videogame consoles introduced in {0}" xml:space="preserve">
<value>Videoconsolas introducidas en {0}</value>
<comment>Consoles introduced in, {0} is a year</comment>
</data>
<data name="{0} videogame consoles found in the database." xml:space="preserve">
<value>{0} videoconsolas en la base de datos</value>
<comment>Consoles found by search, {0} is number</comment>
</data>
<data name="There are no videogame consoles found in the database that start with this letter." xml:space="preserve">
<value>No se encontraron videoconsolas en la base de datos cuyo nombre comience por esa letra.</value>
<comment>No consoles in DB with that letter</comment>
</data>
<data name="There are no videogame consoles found introduced this year." xml:space="preserve">
<value>No se encontraron videoconsolas en la base de datos introducidos en ese año.</value>
<comment>No consoles in DB from that year</comment>
</data>
</root>

View File

@@ -0,0 +1,92 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : ConsolesService.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Consoles service
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database;
using Marechai.Database.Models;
using Marechai.ViewModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Localization;
namespace Marechai.Services
{
public class ConsolesService
{
readonly MarechaiContext _context;
readonly IStringLocalizer<ConsolesService> _l;
public ConsolesService(MarechaiContext context, IStringLocalizer<ConsolesService> localizer)
{
_context = context;
_l = localizer;
}
public async Task<int> GetConsolesCountAsync() =>
await _context.Machines.CountAsync(c => c.Type == MachineType.Console);
public Task<int> GetMinimumYearAsync() => _context.
Machines.Where(t => t.Type == MachineType.Console &&
t.Introduced.HasValue &&
t.Introduced.Value.Year > 1000).
MinAsync(t => t.Introduced.Value.Year);
public Task<int> GetMaximumYearAsync() => _context.
Machines.Where(t => t.Type == MachineType.Console &&
t.Introduced.HasValue &&
t.Introduced.Value.Year > 1000).
MaxAsync(t => t.Introduced.Value.Year);
public async Task<List<MachineViewModel>> GetConsolesByLetterAsync(char c) =>
await _context.Machines.Include(m => m.Company).
Where(m => m.Type == MachineType.Console && EF.Functions.Like(m.Name, $"{c}%")).
OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new MachineViewModel
{
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
}).ToListAsync();
public async Task<List<MachineViewModel>> GetConsolesByYearAsync(int year) =>
await _context.Machines.Include(m => m.Company).
Where(m => m.Type == MachineType.Console && m.Introduced != null &&
m.Introduced.Value.Year == year).OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new MachineViewModel
{
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
}).ToListAsync();
public async Task<List<MachineViewModel>> GetConsolesAsync() =>
await _context.Machines.Include(m => m.Company).Where(m => m.Type == MachineType.Console).
OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new MachineViewModel
{
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
}).ToListAsync();
}
}

View File

@@ -44,6 +44,7 @@ namespace Marechai.Services
services.AddScoped<NewsService>(); services.AddScoped<NewsService>();
services.AddScoped<CompaniesService>(); services.AddScoped<CompaniesService>();
services.AddScoped<ComputersService>(); services.AddScoped<ComputersService>();
services.AddScoped<ConsolesService>();
} }
} }
} }

View File

@@ -1,60 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : ByLetter.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Lists computers by letter (or all)
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Consoles";
}
@model Marechai.Database.Models.Machine[]
<p>Search results:</p>
<p align="center">
@if (ViewBag.Letter != '\0')
{
<b>@ViewBag.Letter</b>
<br />
}
@if (Model.Any())
{
<p>
@Model.Count() computers found in the database.
<br />
@foreach (var console in Model)
{
<a asp-controller="Machine" asp-action="View" asp-route-id="@console.Id">
@console.Company.Name @console.Name</a>
<br />
}
</p>
}
else
{
<p>There are no videoconsoles found in the database that start with this letter.</p>
}
</p>

View File

@@ -1,56 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : ByYear.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Lists computers by letter (or all)
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Computers";
}
@model Marechai.Database.Models.Machine[]
<p>Search results:</p>
<p align="center">
<b>@ViewBag.Year</b>
<br />
@if (Model.Any())
{
<p>
@Model.Count() videoconsoles found in the database.
<br />
@foreach (var console in Model)
{
<a asp-controller="Machine" asp-action="View" asp-route-id="@console.Id">
@console.Company.Name @console.Name</a>
<br />
}
</p>
}
else
{
<p>There are no videoconsoles found in the database released this year.</p>
}
</p>

View File

@@ -1,236 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Contact.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Contact page
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Videoconsoles";
}
<p>
Here you can consult our database.
<br />
In this database you can find technical information as well as videoconsoles history, catalogued by companies, alfabetically and by release date.
<br />
@ViewBag.ItemCount videoconsoles actually catalogued in the database.
</p>
<p>
<br>
<br>
Search by companies
<br>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="Q">
Q
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="W">
W
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="E">
E
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="R">
R
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="T">
T
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="Y">
Y
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="U">
U
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="I">
I
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="O">
O
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="P">
P
</a>
<br>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="A">
A
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="S">
S
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="D">
D
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="F">
F
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="G">
G
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="H">
H
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="J">
J
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="K">
K
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="L">
L
</a>
<br>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="Z">
Z
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="X">
X
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="C">
C
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="V">
V
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="B">
B
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="N">
N
</a>
<a asp-action="ByLetter" asp-controller="Company" asp-route-id="M">
M
</a>
<br>
<a asp-action="ByLetter" asp-controller="Company">
All companies
</a>
</p>
<p>
Alfabetically search
<br>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="Q">
Q
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="W">
W
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="E">
E
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="R">
R
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="T">
T
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="Y">
Y
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="U">
U
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="I">
I
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="O">
O
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="P">
P
</a>
<br>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="A">
A
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="S">
S
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="D">
D
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="F">
F
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="G">
G
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="H">
H
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="J">
J
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="K">
K
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="L">
L
</a>
<br>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="Z">
Z
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="X">
X
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="C">
C
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="V">
V
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="B">
B
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="N">
N
</a>
<a asp-action="ByLetter" asp-controller="Console" asp-route-id="M">
M
</a>
<br>
<a asp-action="ByLetter" asp-controller="Console">
All consoles
</a>
</p>
<p>
Search by year
<br>
@{ var counter = 0; }
@for (int i = ViewBag.MinYear; i <= ViewBag.MaxYear; i++)
{
{
counter++;
}
<a asp-action=ByYear asp-controller=Console asp-route-id=@i>
@i
</a>
if (counter % 8 == 0)
{
<br />
}
}
</p>