Add console controller and views.

This commit is contained in:
2018-04-15 02:31:23 +01:00
parent a558c139b0
commit 3ded57a24d
14 changed files with 1302 additions and 10 deletions

View File

@@ -0,0 +1,72 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ConsoleCompanyController.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Console company 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-2018 Natalia Portillo
*******************************************************************************/
using cicm_web.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
namespace cicm_web.Controllers
{
public class ConsoleCompanyController : Controller
{
readonly IHostingEnvironment hostingEnvironment;
public ConsoleCompanyController(IHostingEnvironment env)
{
hostingEnvironment = env;
}
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;
ConsoleCompany[] companies =
id == '\0' ? ConsoleCompany.GetAllItems() : ConsoleCompany.GetItemsStartingWithLetter(id);
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(companies);
}
public IActionResult View(int id)
{
ConsoleCompany company = ConsoleCompany.GetItem(id);
ViewBag.Company = company;
Console[] consoles = Console.GetItemsFromCompany(id);
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(consoles);
}
}
}

View File

@@ -0,0 +1,90 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ConsoleController.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videograme 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-2018 Natalia Portillo
*******************************************************************************/
using System.Collections.Generic;
using System.Linq;
using cicm_web.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Computer = Cicm.Database.Schemas.Computer;
namespace cicm_web.Controllers
{
public class ConsoleController : Controller
{
readonly IHostingEnvironment hostingEnvironment;
public ConsoleController(IHostingEnvironment env)
{
hostingEnvironment = env;
}
public IActionResult Index()
{
Program.Database.Operations.GetConsoles(out List<Cicm.Database.Schemas.Console> consoles);
ViewBag.ItemCount = consoles.Count;
ViewBag.MinYear = consoles.Where(t => t.Year > 1000).Min(t => t.Year);
ViewBag.MaxYear = consoles.Where(t => t.Year > 1000).Max(t => t.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;
ConsoleMini[] consoles =
id == '\0' ? ConsoleMini.GetAllItems() : ConsoleMini.GetItemsStartingWithLetter(id);
return View(consoles);
}
public IActionResult ByYear(int id)
{
ViewBag.Year = id;
return View(ConsoleMini.GetItemsFromYear(id));
}
public IActionResult View(int id)
{
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(Models.Console.GetItem(id));
}
}
}

View File

@@ -28,6 +28,7 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -71,10 +72,11 @@ namespace cicm_web.Models
public static Console[] GetItemsFromCompany(int id) public static Console[] GetItemsFromCompany(int id)
{ {
List<Cicm.Database.Schemas.Console> dbItems = null; List<Cicm.Database.Schemas.Console> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoles(out dbItems, id); bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null; if(result == null || result.Value == false || dbItems == null) return null;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as Console[]; // TODO: Company chosen by DB
return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Name).ToArray();
} }
public static Console GetItem(int id) public static Console GetItem(int id)
@@ -135,4 +137,57 @@ namespace cicm_web.Models
return item; return item;
} }
} }
public class ConsoleMini
{
public ConsoleCompany Company;
public int Id;
public string Name;
public static ConsoleMini[] GetAllItems()
{
List<Cicm.Database.Schemas.Console> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<ConsoleMini> items = new List<ConsoleMini>();
foreach(Cicm.Database.Schemas.Console dbItem in dbItems) items.Add(TransformItem(dbItem));
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
}
public static ConsoleMini[] GetItemsStartingWithLetter(char letter)
{
List<Cicm.Database.Schemas.Console> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<ConsoleMini> items = new List<ConsoleMini>();
foreach(Cicm.Database.Schemas.Console dbItem in dbItems)
if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
items.Add(TransformItem(dbItem));
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
}
public static ConsoleMini[] GetItemsFromYear(int year)
{
List<Cicm.Database.Schemas.Console> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<ConsoleMini> items = new List<ConsoleMini>();
foreach(Cicm.Database.Schemas.Console dbItem in dbItems)
if(dbItem.Year == year)
items.Add(TransformItem(dbItem));
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
}
static ConsoleMini TransformItem(Cicm.Database.Schemas.Console dbItem)
{
return new ConsoleMini {Company = ConsoleCompany.GetItem(dbItem.Company), Id = dbItem.Id, Name = dbItem.Name};
}
}
} }

View File

@@ -28,7 +28,9 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace cicm_web.Models namespace cicm_web.Models
{ {
@@ -50,12 +52,18 @@ namespace cicm_web.Models
Program.Database?.Operations.GetConsoleCompanies(out dbItems); Program.Database?.Operations.GetConsoleCompanies(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null; if(result == null || result.Value == false || dbItems == null) return null;
List<ConsoleCompany> items = new List<ConsoleCompany>(); return dbItems.Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
}
foreach(Cicm.Database.Schemas.ConsoleCompany dbItem in dbItems) public static ConsoleCompany[] GetItemsStartingWithLetter(char letter)
items.Add(new ConsoleCompany {Id = dbItem.Id, Name = dbItem.Name}); {
List<Cicm.Database.Schemas.ConsoleCompany> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoleCompanies(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
return items.ToArray(); return dbItems
.Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
.Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
} }
} }
} }

View File

@@ -76,6 +76,6 @@
} }
else else
{ {
<p>There are no computers found in the database that start with this letter.</p> <p>There are no companies found in the database that start with this letter.</p>
} }
</p> </p>

View File

@@ -59,6 +59,7 @@
</b> </b>
} }
<b>@Model.Company.Name @Model.Model</b>
<table border=0 <table border=0
width=100%> width=100%>

View File

@@ -0,0 +1,57 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// 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-2018 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Consoles";
}
@model IEnumerable<ConsoleMini>
<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(ConsoleMini console in @Model)
{
<a asp-controller="Console" 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

@@ -0,0 +1,59 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// 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-2018 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Computers";
}
@model IEnumerable<ConsoleMini>
<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(ConsoleMini console in Model)
{
<a asp-controller="Console"
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

@@ -0,0 +1,341 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// 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-2018 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=ConsoleCompany
asp-route-id=Q>
Q
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=W>
W
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=E>
E
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=R>
R
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=T>
T
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=Y>
Y
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=U>
U
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=I>
I
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=O>
O
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=P>
P
</a>
<br>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=A>
A
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=S>
S
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=D>
D
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=F>
F
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=G>
G
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=H>
H
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=J>
J
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=K>
K
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=L>
L
</a>
<br>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=Z>
Z
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=X>
X
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=C>
C
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=V>
V
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=B>
B
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=N>
N
</a>
<a asp-action=ByLetter
asp-controller=ConsoleCompany
asp-route-id=M>
M
</a>
<br>
<a asp-action=ByLetter
asp-controller=ConsoleCompany>
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 computers
</a>
</p>
<p>
Search by year
<br>
@{ int 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>

View File

@@ -0,0 +1,447 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Index.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Index page (and news)
//
// --[ 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-2018 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Videoconsoles";
}
@using System.IO
@model cicm_web.Models.Console
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".gif")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".gif"))"
alt="">
}
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".jpg")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".jpg"))"
alt="">
}
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".png")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", Model.Company.Id + ".png"))"
alt="">
}
@if(Model.Year == 1000)
{
<b>
<center>PROTOTYPE</center>
</b>
}
<b>@Model.Company.Name @Model.Name</b>
<table border=0
width=100%>
@if(Model.Year != 1000)
{
<tr>
<th scope=row
width="37%">
<div align=right>
Year
</div>
</th>
<td width="63%">
@Model.Year
</td>
</tr>
}
<tr>
<th scope=row>
<div align=right>
Primary processor
</div>
</th>
@if(Model.Cpu1.Id != 4)
{
if(Model.Cpu1.Id != 5)
{
if(Model.Mhz1 > 0)
{
if(Model.Bits > 0)
{
<td>@Model.Cpu1.Name @("@") @($"{Model.Mhz1}Mhz") (@Model.Bits bits)</td>
}
else
{
<td>@Model.Cpu1.Name @("@") @($"{Model.Mhz1}Mhz")</td>
}
}
else
{
<td>@Model.Cpu1.Name</td>
}
}
else
{
<td>Unknown data</td>
}
}
else
{ <td>None</td> }
</tr>
@if(Model.Cpu2 != null)
{
<tr>
<th scope=row>
<div align=right>
Secondary processor
</div>
</th>
@if(Model.Cpu2.Id != 4)
{
if(Model.Cpu2.Id != 5)
{
if(Model.Mhz2 > 0)
{
if(Model.Bits > 0)
{
<td>@Model.Cpu2.Name @("@") @($"{Model.Mhz2}Mhz") (@Model.Bits bits)</td>
}
else
{
<td>@Model.Cpu2.Name @("@") @($"{Model.Mhz2}Mhz")</td>
}
}
else
{
<td>@Model.Cpu2.Name</td>
}
}
else
{
<td>Unknown data</td>
}
}
else
{ <td>None</td> }
</tr>
}
<tr>
<th scope=row>
<div align=right>
RAM
</div>
</th>
@if(Model.Ram > 1024)
{
if(Model.Ram > 1048576)
{
<td>@($"{Model.Ram / 1048576}") Gbytes</td>
}
else
{
<td>@($"{Model.Ram / 1024}") Mbytes</td>
}
}
else
{
if(Model.Ram == 0)
{
<td>Unknown data</td>
}
else
{
<td>@Model.Ram Kbytes</td>
}
}
</tr>
<tr>
<th scope=row>
<div align=right>
ROM
</div>
</th>
@if(Model.Rom > 1024)
{
if(Model.Rom > 1048576)
{
<td>@($"{Model.Rom / 1048576}") Gbytes</td>
}
else
{
<td>@($"{Model.Rom / 1024}") Mbytes</td>
}
}
else
{
if(Model.Rom == 0)
{
<td>Unknown data</td>
}
else
{
<td>@Model.Rom Kbytes</td>
}
}
</tr>
<tr>
<th scope=row>
<div align=right>
Graphics processor
</div>
</th>
@if(Model.Gpu.Id > 1)
{
if(Model.Gpu.Id > 2)
{
<td>@Model.Gpu.Name</td>
}
else
{
<td>Unknown data</td>
}
}
else
{ <td>None</td> }
</tr>
<tr>
<th scope=row>
<div align=right>
Video memory
</div>
</th>
@if(Model.Vram > 1024)
{
if(Model.Vram > 1048576)
{
<td>@($"{Model.Vram / 1048576}") Gbytes</td>
}
else
{
<td>@($"{Model.Vram / 1024}") Mbytes</td>
}
}
else
{
if(Model.Vram == 0)
{
<td>Unknown data</td>
}
else
{
<td>@Model.Vram Kbytes</td>
}
}
</tr>
<tr>
<th scope=row>
<div align=right>
Video resolution
</div>
</th>
@if(Model.Resolution != "???")
{
<td>@Model.Resolution</td>
}
else
{
<td>Unknown data</td>
}
</tr>
<tr>
<th scope=row>
<div align=right>
Colors
</div>
</th>
@if(Model.Colors > 0)
{
if(Model.Palette > 0)
{
<td>@Model.Colors from a palette of @Model.Palette</td>
}
else
{
<td>@Model.Colors</td>
}
}
else
{
<td>Unknown data</td>
}
</tr>
<tr>
<th scope=row>
<div align=right>
Sound processor
</div>
</th>
@if(Model.Spu.Id > 1)
{
if(Model.Spu.Id > 2)
{
if(Model.SoundChannels > 0)
{
<td>@Model.Spu.Name (@Model.SoundChannels channels)</td>
}
else
{
<td>@Model.Spu.Name</td>
}
}
else
{
<td>Unknown data</td>
}
}
else
{ <td>None</td> }
</tr>
<tr>
<th scope=row>
<div align=right>
Music synthetizer
</div>
</th>
@if(Model.Mpu.Id > 1)
{
if(Model.Mpu.Id > 2)
{
if(Model.MusicChannels > 0)
{
<td>@Model.Mpu.Name (@Model.MusicChannels channels)</td>
}
else
{
<td>@Model.Mpu.Name</td>
}
}
else
{
<td>Unknown data</td>
}
}
else
{ <td>None</td> }
</tr>
@if(Model.Format != null)
{
<tr>
<th scope=row>
<div align=right>
Primary disk
</div>
</th>
@if(Model.Format.Id != 30)
{
if(Model.Format.Id != 8)
{
if(Model.Format.Id != 6)
{
string cap1Bytes = Model.Cap > 1024 ? (Model.Cap > 1048576 ? $"{Model.Cap / 1048576} GBytes" : $"{Model.Cap / 1024} MBytes") : (Model.Cap > 0 ? $"{Model.Cap} Kbytes" : "Unknown capacity");
if(Model.Format.Id != 10)
{
if(Model.Format.Id != 15)
{
if(Model.Format.Id != 16)
{
if(Model.Format.Id != 36)
{
if(Model.Format.Id != 22)
{
if(Model.Format.Id != 23)
{
if(Model.Format.Id != 39)
{
if(Model.Format.Id != 31)
{
<td>@Model.Format.Description (@cap1Bytes)</td>
}
else
{
<td>Propietary (@cap1Bytes)</td>
}
}
else
{
<td>Digital tape (@cap1Bytes)</td>
}
}
else
{
<td>Punched card (@cap1Bytes)</td>
}
}
else
{
<td>Chip card (@cap1Bytes)</td>
}
}
else
{
<td>Magnetic card (@cap1Bytes)</td>
}
}
else
{
<td>Memory (@cap1Bytes)</td>
}
}
else
{
<td>Magneto-optical (@cap1Bytes)</td>
}
}
else
{
<td>Optical disk (@cap1Bytes)</td>
}
}
else
{
string cap1Bits = Model.Cap > 1000 ? (Model.Cap > 1000000 ? $"{Model.Cap / 1000000} GBits" : $"{Model.Cap / 1000} MBits") : (Model.Cap > 0 ? $"{Model.Cap} KBits" : "Unknown capacity");
<td>Cartridge (@cap1Bits)</td>
}
}
else
{
<td>Standard audio cassette (@Model.Cap bps)</td>
}
}
else
{ <td>None</td> }
</tr>
}
</table>
@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/photos/consoles", Model.Id + ".jpg")))
{
<img src="@System.IO.Path.Combine("/assets/photos/consoles", Model.Id + ".jpg")"
alt="">
}

View File

@@ -0,0 +1,81 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ByLetter.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Lists companies 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-2018 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Console companies";
}
@using System.IO
@model IEnumerable<ConsoleCompany>
<p>Search results:</p>
<p align=center>
@if(ViewBag.Letter != '\0')
{
<b>@ViewBag.Letter</b>
<br />
}
@if(Model.Any())
{
<p>
@Model.Count() companies found in the database.<br />
@foreach(ConsoleCompany company in Model)
{
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".gif")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".gif"))"
alt="">
}
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".jpg")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".jpg"))"
alt="">
}
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".png")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", company.Id + ".png"))"
alt="">
}
<a asp-controller="ConsoleCompany"
asp-action="View"
asp-route-id="@company.Id">
@company.Name</a>
<br />
}
</p>
}
else
{
<p>There are no console companies found in the database that start with this letter.</p>
}
</p>

View File

@@ -0,0 +1,80 @@
@{
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ByLetter.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Lists computers by company
//
// --[ 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-2018 Natalia Portillo
*******************************************************************************/
ViewData["Title"] = "Companies";
}
@using System.IO
@model IEnumerable<cicm_web.Models.Console>
<p>Search results:</p>
<p align=center>
@if(ViewBag.Company != null)
{
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".gif")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".gif"))"
alt="">
}
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".jpg")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".jpg"))"
alt="">
}
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".png")))
{
<img src="@(System.IO.Path.Combine("/assets/logos/consoles", ViewBag.Company.Id + ".png"))"
alt="">
}
<b>@ViewBag.Company.Name</b>
<br />
}
@if(Model.Any())
{
<p>
@Model.Count() computers found in the database.<br />
@foreach(cicm_web.Models.Console console in Model)
{
<a asp-controller="Console"
asp-action="View"
asp-route-id="@console.Id">
@console.Name</a>
<br />
}
</p>
}
else
{
<p>There are no videoconsoles found in the database that belong to that company.</p>
}
</p>

View File

@@ -103,8 +103,9 @@
</a> </a>
<div class=dropdown-divider> <div class=dropdown-divider>
</div> </div>
<a class=dropdown-item <a asp-action=Index
href=#> asp-controller=Console
class=dropdown-item>
Consoles Consoles
</a> </a>
</div> </div>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<Version>3.0.99.84</Version> <Version>3.0.99.86</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>