Use EntityFramework on machine controller.

This commit is contained in:
2018-08-06 23:24:00 +01:00
parent dc62d1f2f4
commit 26c197f28c
2 changed files with 471 additions and 471 deletions

View File

@@ -28,7 +28,8 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using cicm_web.Models; using System.Linq;
using Cicm.Database.Models;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -36,18 +37,20 @@ namespace cicm_web.Controllers
{ {
public class MachineController : Controller public class MachineController : Controller
{ {
readonly cicmContext _context;
readonly IHostingEnvironment hostingEnvironment; readonly IHostingEnvironment hostingEnvironment;
public MachineController(IHostingEnvironment env) public MachineController(IHostingEnvironment env, cicmContext context)
{ {
hostingEnvironment = env; hostingEnvironment = env;
_context = context;
} }
public IActionResult View(int id) public IActionResult View(int id)
{ {
ViewBag.WebRootPath = hostingEnvironment.WebRootPath; ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(Machine.GetItem(id)); return View(_context.Machines.FirstOrDefault(m => m.Id == id));
} }
} }
} }

View File

@@ -33,8 +33,12 @@
} }
@using System.IO @using System.IO
@using Cicm.Database @using Cicm.Database
@model Machine @using Cicm.Database.Models
@using MemoryByMachine = Cicm.Database.Models.MemoryByMachine
@using SoundByMachine = Cicm.Database.Models.SoundByMachine
@using StorageByMachine = Cicm.Database.Models.StorageByMachine
@model Cicm.Database.Models.Machine
@* TODO
<p align="center"> <p align="center">
@if(Model.Company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.LastLogo.Guid + ".svg"))) @if(Model.Company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.LastLogo.Guid + ".svg")))
{ {
@@ -56,8 +60,11 @@
</picture> </picture>
} }
</p> </p>
*@
@if(Model.Introduced.Year == 1000) @{ int counter = 0; }
@if(Model.Introduced.HasValue && Model.Introduced.Value.Year == 1000)
{ {
<b> <b>
<div style="text-align: center;">PROTOTYPE</div> <div style="text-align: center;">PROTOTYPE</div>
@@ -71,7 +78,7 @@
@Model.Company.Name</a> @Model.Name</b> @Model.Company.Name</a> @Model.Name</b>
<table width="100%"> <table width="100%">
@if(Model.Introduced.Year != 1000) @if(Model.Introduced.HasValue && Model.Introduced.Value.Year != 1000)
{ {
<tr> <tr>
<th scope=row <th scope=row
@@ -83,8 +90,8 @@
<td width="63%"> <td width="63%">
<a asp-controller="Computer" <a asp-controller="Computer"
asp-action="ByYear" asp-action="ByYear"
asp-route-id="@Model.Introduced.Year"> asp-route-id="@Model.Introduced.Value.Year">
@Model.Introduced.ToLongDateString()</a> @Model.Introduced.Value.ToLongDateString()</a>
</td> </td>
</tr> </tr>
} }
@@ -119,7 +126,7 @@
</td> </td>
</tr> </tr>
} }
@if(Model.Processors != null && Model.Processors.Length > 0) @if(Model.Processors.Count > 0)
{ {
<tr> <tr>
<th scope=row> <th scope=row>
@@ -129,31 +136,30 @@
</th> </th>
<td> <td>
<table> <table>
@for(int i = 0; i < Model.Processors.Length; i++) @{ counter = 0; }
{ @foreach(ProcessorsByMachine processorByMachine in Model.Processors)
if(Model.Processors[i] != null)
{ {
<tr> <tr>
<td> <td>
@if(Model.Processors[i].Speed > 0) { @(Model.Processors[i].Processor.GprSize > 0 ? $"{Model.Processors[i].Processor.Name} @ {Model.Processors[i].Speed}Mhz ({Model.Processors[i].Processor.GprSize} bits)" : $"{Model.Processors[i].Processor.Name} @ {Model.Processors[i].Speed}Mhz") } @if(processorByMachine.Speed > 0) { @(processorByMachine.Processor.GprSize > 0 ? $"{processorByMachine.Processor.Name} @ {processorByMachine.Speed}Mhz ({processorByMachine.Processor.GprSize} bits)" : $"{processorByMachine.Processor.Name} @ {processorByMachine.Speed}Mhz") }
else else
{ @($"{Model.Processors[i].Processor.Name}") } { @($"{processorByMachine.Processor.Name}") }
<a aria-controls="@($"cpuInfo{i}")" <a aria-controls="@($"cpuInfo{counter}")"
aria-expanded="false" aria-expanded="false"
class="btn btn-link" class="btn btn-link"
data-toggle="collapse" data-toggle="collapse"
href="@($"#cpuInfo{i}")"> href="@($"#cpuInfo{counter}")">
+info +info
</a> </a>
<div class="collapse" <div class="collapse"
id="@($"cpuInfo{i}")"> id="@($"cpuInfo{counter}")">
<div class="card card-body"> <div class="card card-body">
<table> <table>
@if(Model.Processors[i].Processor.ModelCode != null && Model.Processors[i].Processor.ModelCode != Model.Processors[i].Processor.Name) @if(processorByMachine.Processor.ModelCode != null && processorByMachine.Processor.ModelCode != processorByMachine.Processor.Name)
{ {
<tr> <tr>
<td>Model</td> <td>Model</td>
<td>@Model.Processors[i].Processor.ModelCode</td> <td>@processorByMachine.Processor.ModelCode</td>
</tr> </tr>
} }
<tr> <tr>
@@ -161,61 +167,61 @@
<td> <td>
<a asp-controller=Company <a asp-controller=Company
asp-action=View asp-action=View
asp-route-id=@Model.Processors[i].Processor.Company.Id> asp-route-id=@processorByMachine.Processor.Company.Id>
@Model.Processors[i].Processor.Company.Name</a> @processorByMachine.Processor.Company.Name</a>
</td> </td>
</tr> </tr>
@if(Model.Processors[i].Processor.Introduced != DateTime.MinValue) @if(processorByMachine.Processor.Introduced != DateTime.MinValue)
{ {
<tr> <tr>
<td>Introduction date</td> <td>Introduction date</td>
<td>@($"{Model.Processors[i].Processor.Introduced:yyyy}")</td> <td>@($"{processorByMachine.Processor.Introduced:yyyy}")</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.InstructionSet != null) @if(processorByMachine.Processor.InstructionSet != null)
{ {
<tr> <tr>
<td>Instruction set</td> <td>Instruction set</td>
<td>@Model.Processors[i].Processor.InstructionSet.Name</td> <td>@processorByMachine.Processor.InstructionSet.Name</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Speed > 0) @if(processorByMachine.Processor.Speed > 0)
{ {
<tr> <tr>
<td>Nominal speed</td> <td>Nominal speed</td>
<td>@Model.Processors[i].Processor.Speed MHz</td> <td>@processorByMachine.Processor.Speed MHz</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Gpr > 0 || Model.Processors[i].Processor.Fpr > 0 || Model.Processors[i].Processor.Simd > 0) @if(processorByMachine.Processor.Gprs > 0 || processorByMachine.Processor.Fprs > 0 || processorByMachine.Processor.SimdRegisters > 0)
{ {
<tr> <tr>
<td>Registers</td> <td>Registers</td>
<td> <td>
<table> <table>
@if(Model.Processors[i].Processor.Gpr > 0) @if(processorByMachine.Processor.Gprs > 0)
{ {
<tr> <tr>
<td> <td>
@Model.Processors[i].Processor.Gpr general purpose registers of @Model.Processors[i].Processor.GprSize bits @processorByMachine.Processor.Gprs general purpose registers of @processorByMachine.Processor.GprSize bits
@if(Model.Processors[i].Processor.FprSize > 0 && Model.Processors[i].Processor.Fpr == 0) { @($", that can be used as floating point registers of {Model.Processors[i].Processor.FprSize}") } @if(processorByMachine.Processor.FprSize > 0 && processorByMachine.Processor.Fprs == 0) { @($", that can be used as floating point registers of {processorByMachine.Processor.FprSize}") }
@if(Model.Processors[i].Processor.SimdSize > 0 && Model.Processors[i].Processor.Simd == 0) { @($", that can be used as SIMD registers of {Model.Processors[i].Processor.FprSize}") } @if(processorByMachine.Processor.SimdSize > 0 && processorByMachine.Processor.SimdRegisters == 0) { @($", that can be used as SIMD registers of {processorByMachine.Processor.FprSize}") }
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Fpr > 0) @if(processorByMachine.Processor.Fprs > 0)
{ {
<tr> <tr>
<td> <td>
@Model.Processors[i].Processor.Fpr floating-point registers of @Model.Processors[i].Processor.FprSize bits @processorByMachine.Processor.Fprs floating-point registers of @processorByMachine.Processor.FprSize bits
@if(Model.Processors[i].Processor.SimdSize > 0 && Model.Processors[i].Processor.Simd == 0) { @($", that can be used as SIMD registers of {Model.Processors[i].Processor.FprSize}") } @if(processorByMachine.Processor.SimdSize > 0 && processorByMachine.Processor.SimdRegisters == 0) { @($", that can be used as SIMD registers of {processorByMachine.Processor.FprSize}") }
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Simd > 0) @if(processorByMachine.Processor.SimdRegisters > 0)
{ {
<tr> <tr>
<td> <td>
@Model.Processors[i].Processor.Simd <abbr title="Single instruction, multiple data">SIMD</abbr>registers of @Model.Processors[i].Processor.SimdSize bits @processorByMachine.Processor.SimdRegisters <abbr title="Single instruction, multiple data">SIMD</abbr>registers of @processorByMachine.Processor.SimdSize bits
</td> </td>
</tr> </tr>
} }
@@ -223,44 +229,44 @@
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Cores > 1) @if(processorByMachine.Processor.Cores > 1)
{ {
<tr> <tr>
<td>Multi-core</td> <td>Multi-core</td>
<td>@Model.Processors[i].Processor.Cores cores</td> <td>@processorByMachine.Processor.Cores cores</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Cores > 1) @if(processorByMachine.Processor.Cores > 1)
{ {
<tr> <tr>
<td> <td>
<abbr title="Simultanoeus multithreading">SMT</abbr> <abbr title="Simultanoeus multithreading">SMT</abbr>
</td> </td>
<td> <td>
@Model.Processors[i].Processor.ThreadsPerCore threads @processorByMachine.Processor.ThreadsPerCore threads
@if(Model.Processors[i].Processor.Cores > 1) { @(" per core") } @if(processorByMachine.Processor.Cores > 1) { @(" per core") }
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.DataBus > 0 || Model.Processors[i].Processor.AddressBus > 0) @if(processorByMachine.Processor.DataBus > 0 || processorByMachine.Processor.AddrBus > 0)
{ {
<tr> <tr>
<td>Bus</td> <td>Bus</td>
<td> <td>
<table> <table>
@if(Model.Processors[i].Processor.DataBus > 0) @if(processorByMachine.Processor.DataBus > 0)
{ {
<tr> <tr>
<td> <td>
@Model.Processors[i].Processor.DataBus-bit data @processorByMachine.Processor.DataBus-bit data
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.AddressBus > 0) @if(processorByMachine.Processor.AddrBus > 0)
{ {
<tr> <tr>
<td> <td>
@Model.Processors[i].Processor.AddressBus-bit address @processorByMachine.Processor.AddrBus-bit address
</td> </td>
</tr> </tr>
} }
@@ -269,41 +275,41 @@
</tr> </tr>
} }
@if(Model.Processors[i].Processor.L1Instruction > 0 || Model.Processors[i].Processor.L1Data > 0 || Model.Processors[i].Processor.L2 > 0 || Model.Processors[i].Processor.L2 > 0) @if(processorByMachine.Processor.L1Instruction > 0 || processorByMachine.Processor.L1Data > 0 || processorByMachine.Processor.L2 > 0 || processorByMachine.Processor.L2 > 0)
{ {
<tr> <tr>
<td>Cache</td> <td>Cache</td>
<td> <td>
<table> <table>
@if(Model.Processors[i].Processor.L1Instruction > 0) @if(processorByMachine.Processor.L1Instruction > 0)
{ {
<tr> <tr>
<td> <td>
@(Model.Processors[i].Processor.L1Data < 0 ? $"{Model.Processors[i].Processor.L1Instruction}KiB combined instruction-data L1" : $"{Model.Processors[i].Processor.L1Instruction}KiB instruction L1") @(processorByMachine.Processor.L1Data < 0 ? $"{processorByMachine.Processor.L1Instruction}KiB combined instruction-data L1" : $"{processorByMachine.Processor.L1Instruction}KiB instruction L1")
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.L1Data > 0) @if(processorByMachine.Processor.L1Data > 0)
{ {
<tr> <tr>
<td> <td>
@($"{Model.Processors[i].Processor.L1Data}KiB data L1") @($"{processorByMachine.Processor.L1Data}KiB data L1")
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.L2 > 0) @if(processorByMachine.Processor.L2 > 0)
{ {
<tr> <tr>
<td> <td>
@($"{Model.Processors[i].Processor.L2}KiB L2") @($"{processorByMachine.Processor.L2}KiB L2")
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.L3 > 0) @if(processorByMachine.Processor.L3 > 0)
{ {
<tr> <tr>
<td> <td>
@($"{Model.Processors[i].Processor.L3}KiB L3") @($"{processorByMachine.Processor.L3}KiB L3")
</td> </td>
</tr> </tr>
} }
@@ -311,42 +317,42 @@
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Package != null) @if(processorByMachine.Processor.Package != null)
{ {
<tr> <tr>
<td>Package</td> <td>Package</td>
<td>@Model.Processors[i].Processor.Package</td> <td>@processorByMachine.Processor.Package</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Process != null || Model.Processors[i].Processor.ProcessNm > 0) @if(processorByMachine.Processor.Process != null || processorByMachine.Processor.ProcessNm > 0)
{ {
<tr> <tr>
<td>Manufacturing process</td> <td>Manufacturing process</td>
<td> <td>
@if(Model.Processors[i].Processor.Process != null && Model.Processors[i].Processor.ProcessNm > 0) @if(processorByMachine.Processor.Process != null && processorByMachine.Processor.ProcessNm > 0)
{ {
@Model.Processors[i].Processor.Process @processorByMachine.Processor.Process
@("@") @("@")
@(Model.Processors[i].Processor.ProcessNm > 100 ? $"{Model.Processors[i].Processor.ProcessNm / 100}µm" : $"{Model.Processors[i].Processor.ProcessNm}nm") @(processorByMachine.Processor.ProcessNm > 100 ? $"{processorByMachine.Processor.ProcessNm / 100}µm" : $"{processorByMachine.Processor.ProcessNm}nm")
} }
else if(Model.Processors[i].Processor.ProcessNm > 0) { @(Model.Processors[i].Processor.ProcessNm > 100 ? $"{Model.Processors[i].Processor.ProcessNm / 100}µm" : $"{Model.Processors[i].Processor.ProcessNm}nm") } else if(processorByMachine.Processor.ProcessNm > 0) { @(processorByMachine.Processor.ProcessNm > 100 ? $"{processorByMachine.Processor.ProcessNm / 100}µm" : $"{processorByMachine.Processor.ProcessNm}nm") }
else else
{ @Model.Processors[i].Processor.Process } { @processorByMachine.Processor.Process }
</td> </td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.DieSize > 0) @if(processorByMachine.Processor.DieSize > 0)
{ {
<tr> <tr>
<td>Die size</td> <td>Die size</td>
<td>@Model.Processors[i].Processor.DieSize mm&sup2;</td> <td>@processorByMachine.Processor.DieSize mm&sup2;</td>
</tr> </tr>
} }
@if(Model.Processors[i].Processor.Transistors > 0) @if(processorByMachine.Processor.Transistors > 0)
{ {
<tr> <tr>
<td>Transistors</td> <td>Transistors</td>
<td>@Model.Processors[i].Processor.Transistors</td> <td>@processorByMachine.Processor.Transistors</td>
</tr> </tr>
} }
</table> </table>
@@ -355,13 +361,14 @@
</td> </td>
</tr> </tr>
}
counter++;
} }
</table> </table>
</td> </td>
</tr> </tr>
} }
@if(Model.Memories != null && Model.Memories.Length > 0) @if(Model.Memory != null && Model.Memory.Count > 0)
{ {
<tr> <tr>
<th scope=row> <th scope=row>
@@ -371,7 +378,7 @@
</th> </th>
<td> <td>
<table> <table>
@foreach(MemoryByMachine memory in Model.Memories) @foreach(MemoryByMachine memory in Model.Memory)
{ {
string memValue; string memValue;
if(memory.Size > 1073741824) { memValue = $"{memory.Size / 1073741824} GiB"; } if(memory.Size > 1073741824) { memValue = $"{memory.Size / 1073741824} GiB"; }
@@ -397,7 +404,7 @@
</td> </td>
</tr> </tr>
} }
@if(Model.Gpus != null && Model.Gpus.Length > 0) @if(Model.Gpus.Count > 0)
{ {
<tr> <tr>
<th scope=row> <th scope=row>
@@ -407,23 +414,22 @@
</th> </th>
<td> <td>
<table> <table>
@for(int i = 0; i < Model.Gpus.Length; i++) @{ counter = 0; }
@foreach(GpusByMachine gpuByMachine in Model.Gpus)
{ {
if(Model.Gpus[i] != null) if(gpuByMachine.Gpu.Id == -2)
{
if(Model.Gpus[i].Gpu.Id == -2)
{ {
<td> <td>
Framebuffer Framebuffer
<a aria-controls="@($"gpuInfo{i}")" <a aria-controls="@($"gpuInfo{counter}")"
aria-expanded="false" aria-expanded="false"
class="btn btn-link" class="btn btn-link"
data-toggle="collapse" data-toggle="collapse"
href="@($"#gpuInfo{i}")"> href="@($"#gpuInfo{counter}")">
+info +info
</a> </a>
<div class="collapse" <div class="collapse"
id="@($"gpuInfo{i}")"> id="@($"gpuInfo{counter}")">
<div class="card card-body"> <div class="card card-body">
This computer directly draws pixels from software to a memory region that's converted to video output by a <abbr title="Digital to Analog Converter">DAC</abbr> or similar without using any specific graphics processing unit. This computer directly draws pixels from software to a memory region that's converted to video output by a <abbr title="Digital to Analog Converter">DAC</abbr> or similar without using any specific graphics processing unit.
</div> </div>
@@ -433,23 +439,23 @@
else else
{ {
<td> <td>
@($"{Model.Gpus[i].Gpu.Name}") @($"{gpuByMachine.Gpu.Name}")
<a aria-controls="@($"gpuInfo{i}")" <a aria-controls="@($"gpuInfo{counter}")"
aria-expanded="false" aria-expanded="false"
class="btn btn-link" class="btn btn-link"
data-toggle="collapse" data-toggle="collapse"
href="@($"#gpuInfo{i}")"> href="@($"#gpuInfo{counter}")">
+info +info
</a> </a>
<div class="collapse" <div class="collapse"
id="@($"gpuInfo{i}")"> id="@($"gpuInfo{counter}")">
<div class="card card-body"> <div class="card card-body">
<table> <table>
@if(Model.Gpus[i].Gpu.ModelCode != null && Model.Gpus[i].Gpu.ModelCode != Model.Gpus[i].Gpu.Name) @if(gpuByMachine.Gpu.ModelCode != null && gpuByMachine.Gpu.ModelCode != gpuByMachine.Gpu.Name)
{ {
<tr> <tr>
<td>Model</td> <td>Model</td>
<td>@Model.Gpus[i].Gpu.ModelCode</td> <td>@gpuByMachine.Gpu.ModelCode</td>
</tr> </tr>
} }
<tr> <tr>
@@ -457,53 +463,53 @@
<td> <td>
<a asp-controller=Company <a asp-controller=Company
asp-action=View asp-action=View
asp-route-id=@Model.Gpus[i].Gpu.Company.Id> asp-route-id=@gpuByMachine.Gpu.Company.Id>
@Model.Gpus[i].Gpu.Company.Name</a> @gpuByMachine.Gpu.Company.Name</a>
</td> </td>
</tr> </tr>
@if(Model.Gpus[i].Gpu.Introduced != DateTime.MinValue) @if(gpuByMachine.Gpu.Introduced != DateTime.MinValue)
{ {
<tr> <tr>
<td>Introduction date</td> <td>Introduction date</td>
<td>@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")</td> <td>@($"{gpuByMachine.Gpu.Introduced:yyyy}")</td>
</tr> </tr>
} }
@if(Model.Gpus[i].Gpu.Package != null) @if(gpuByMachine.Gpu.Package != null)
{ {
<tr> <tr>
<td>Package</td> <td>Package</td>
<td>@Model.Gpus[i].Gpu.Package</td> <td>@gpuByMachine.Gpu.Package</td>
</tr> </tr>
} }
@if(Model.Gpus[i].Gpu.Process != null || Model.Gpus[i].Gpu.ProcessNm > 0) @if(gpuByMachine.Gpu.Process != null || gpuByMachine.Gpu.ProcessNm > 0)
{ {
<tr> <tr>
<td>Manufacturing process</td> <td>Manufacturing process</td>
<td> <td>
@if(Model.Gpus[i].Gpu.Process != null && Model.Gpus[i].Gpu.ProcessNm > 0) @if(gpuByMachine.Gpu.Process != null && gpuByMachine.Gpu.ProcessNm > 0)
{ {
@Model.Gpus[i].Gpu.Process @gpuByMachine.Gpu.Process
@("@") @("@")
@(Model.Gpus[i].Gpu.ProcessNm > 100 ? $"{Model.Gpus[i].Gpu.ProcessNm / 100}µm" : $"{Model.Gpus[i].Gpu.ProcessNm}nm") @(gpuByMachine.Gpu.ProcessNm > 100 ? $"{gpuByMachine.Gpu.ProcessNm / 100}µm" : $"{gpuByMachine.Gpu.ProcessNm}nm")
} }
else if(Model.Gpus[i].Gpu.ProcessNm > 0) { @(Model.Gpus[i].Gpu.ProcessNm > 100 ? $"{Model.Gpus[i].Gpu.ProcessNm / 100}µm" : $"{Model.Gpus[i].Gpu.ProcessNm}nm") } else if(gpuByMachine.Gpu.ProcessNm > 0) { @(gpuByMachine.Gpu.ProcessNm > 100 ? $"{gpuByMachine.Gpu.ProcessNm / 100}µm" : $"{gpuByMachine.Gpu.ProcessNm}nm") }
else else
{ @Model.Gpus[i].Gpu.Process } { @gpuByMachine.Gpu.Process }
</td> </td>
</tr> </tr>
} }
@if(Model.Gpus[i].Gpu.DieSize > 0) @if(gpuByMachine.Gpu.DieSize > 0)
{ {
<tr> <tr>
<td>Die size</td> <td>Die size</td>
<td>@Model.Gpus[i].Gpu.DieSize mm&sup2;</td> <td>@gpuByMachine.Gpu.DieSize mm&sup2;</td>
</tr> </tr>
} }
@if(Model.Gpus[i].Gpu.Transistors > 0) @if(gpuByMachine.Gpu.Transistors > 0)
{ {
<tr> <tr>
<td>Transistors</td> <td>Transistors</td>
<td>@Model.Gpus[i].Gpu.Transistors</td> <td>@gpuByMachine.Gpu.Transistors</td>
</tr> </tr>
} }
</table> </table>
@@ -511,17 +517,13 @@
</div> </div>
</td> </td>
} }
} counter++;
else
{
<td>Unknown data</td>
}
} }
</table> </table>
</td> </td>
</tr> </tr>
} }
@if(Model.SoundSynths != null && Model.SoundSynths.Length > 0) @if(Model.Sound.Count > 0)
{ {
<tr> <tr>
<th scope=row> <th scope=row>
@@ -531,24 +533,23 @@
</th> </th>
<td> <td>
<table> <table>
@for(int i = 0; i < Model.SoundSynths.Length; i++) @{ counter = 0; }
@foreach(SoundByMachine soundByMachine in Model.Sound)
{ {
<tr> <tr>
@if(Model.SoundSynths[i] != null) @if(soundByMachine.SoundSynth.Id == -2)
{
if(Model.SoundSynths[i].SoundSynth.Id == -2)
{ {
<td> <td>
Software Software
<a aria-controls="@($"synthInfo{i}")" <a aria-controls="@($"synthInfo{counter}")"
aria-expanded="false" aria-expanded="false"
class="btn btn-link" class="btn btn-link"
data-toggle="collapse" data-toggle="collapse"
href="@($"#synthInfo{i}")"> href="@($"#synthInfo{counter}")">
+info +info
</a> </a>
<div class="collapse" <div class="collapse"
id="@($"synthInfo{i}")"> id="@($"synthInfo{counter}")">
<div class="card card-body"> <div class="card card-body">
This computer directly sends data to a <abbr title="Digital to Analog Converter">DAC</abbr> or similar connected to the audio output. This computer directly sends data to a <abbr title="Digital to Analog Converter">DAC</abbr> or similar connected to the audio output.
</div> </div>
@@ -558,106 +559,106 @@
else else
{ {
<td> <td>
@($"{Model.SoundSynths[i].SoundSynth.Name}") @($"{soundByMachine.SoundSynth.Name}")
<a aria-controls="@($"synthInfo{i}")" <a aria-controls="@($"synthInfo{counter}")"
aria-expanded="false" aria-expanded="false"
class="btn btn-link" class="btn btn-link"
data-toggle="collapse" data-toggle="collapse"
href="@($"#synthInfo{i}")"> href="@($"#synthInfo{counter}")">
+info +info
</a> </a>
<div class="collapse" <div class="collapse"
id="@($"synthInfo{i}")"> id="@($"synthInfo{counter}")">
<div class="card card-body"> <div class="card card-body">
<table> <table>
@if(Model.SoundSynths[i].SoundSynth.ModelCode != null && Model.SoundSynths[i].SoundSynth.ModelCode != Model.SoundSynths[i].SoundSynth.Name) @if(soundByMachine.SoundSynth.ModelCode != null && soundByMachine.SoundSynth.ModelCode != soundByMachine.SoundSynth.Name)
{ {
<tr> <tr>
<td>Model</td> <td>Model</td>
<td>@Model.SoundSynths[i].SoundSynth.ModelCode</td> <td>@soundByMachine.SoundSynth.ModelCode</td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.Company != null) @if(soundByMachine.SoundSynth.Company != null)
{ {
<tr> <tr>
<td>Manufacturer</td> <td>Manufacturer</td>
<td> <td>
<a asp-controller=Company <a asp-controller=Company
asp-action=View asp-action=View
asp-route-id=@Model.SoundSynths[i].SoundSynth.Company.Id> asp-route-id=@soundByMachine.SoundSynth.Company.Id>
@Model.SoundSynths[i].SoundSynth.Company.Name</a> @soundByMachine.SoundSynth.Company.Name</a>
</td> </td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.Introduced != DateTime.MinValue) @if(soundByMachine.SoundSynth.Introduced != DateTime.MinValue)
{ {
<tr> <tr>
<td>Introduction date</td> <td>Introduction date</td>
<td>@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")</td> <td>@($"{soundByMachine.SoundSynth.Introduced:yyyy}")</td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.Voices != 0 || Model.SoundSynths[i].SoundSynth.SquareWave != 0 || Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) @if(soundByMachine.SoundSynth.Voices != 0 || soundByMachine.SoundSynth.SquareWave != 0 || soundByMachine.SoundSynth.WhiteNoise != 0)
{ {
<tr> <tr>
<td>Generators</td> <td>Generators</td>
<td> <td>
<table> <table>
@if(Model.SoundSynths[i].SoundSynth.Voices != 0) @if(soundByMachine.SoundSynth.Voices != 0)
{ {
<tr> <tr>
<td>@Model.SoundSynths[i].SoundSynth.Voices voices</td> <td>@soundByMachine.SoundSynth.Voices voices</td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.SquareWave != 0) @if(soundByMachine.SoundSynth.SquareWave != 0)
{ {
<tr> <tr>
<td>@Model.SoundSynths[i].SoundSynth.SquareWave square wave</td> <td>@soundByMachine.SoundSynth.SquareWave square wave</td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) @if(soundByMachine.SoundSynth.WhiteNoise != 0)
{ {
<tr> <tr>
<td>@Model.SoundSynths[i].SoundSynth.WhiteNoise white noise</td> <td>@soundByMachine.SoundSynth.WhiteNoise white noise</td>
</tr> </tr>
} }
</table> </table>
</td> </td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.Depth != 0 || Model.SoundSynths[i].SoundSynth.Frequency > 0) @if(soundByMachine.SoundSynth.Depth != 0 || soundByMachine.SoundSynth.Frequency > 0)
{ {
<tr> <tr>
<td>Sample rate</td> <td>Sample rate</td>
<td> <td>
<table> <table>
@if(Model.SoundSynths[i].SoundSynth.Depth != 0 && Model.SoundSynths[i].SoundSynth.Frequency > 0) @if(soundByMachine.SoundSynth.Depth != 0 && soundByMachine.SoundSynth.Frequency > 0)
{ {
<tr> <tr>
<td>@Model.SoundSynths[i].SoundSynth.Depth bits at @(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")</td> <td>@soundByMachine.SoundSynth.Depth bits at @(soundByMachine.SoundSynth.Frequency > 1000 ? $"{soundByMachine.SoundSynth.Frequency / 1000}KHz" : $"{soundByMachine.SoundSynth.Frequency}Hz")</td>
</tr> </tr>
} }
else if(Model.SoundSynths[i].SoundSynth.Depth != 0) else if(soundByMachine.SoundSynth.Depth != 0)
{ {
<tr> <tr>
<td>@Model.SoundSynths[i].SoundSynth.Depth bits</td> <td>@soundByMachine.SoundSynth.Depth bits</td>
</tr> </tr>
} }
else else
{ {
<tr> <tr>
<td>@(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")</td> <td>@(soundByMachine.SoundSynth.Frequency > 1000 ? $"{soundByMachine.SoundSynth.Frequency / 1000}KHz" : $"{soundByMachine.SoundSynth.Frequency}Hz")</td>
</tr> </tr>
} }
</table> </table>
</td> </td>
</tr> </tr>
} }
@if(Model.SoundSynths[i].SoundSynth.Type != 0) @if(soundByMachine.SoundSynth.Type != 0)
{ {
<tr> <tr>
<td>Synthetizer type</td> <td>Synthetizer type</td>
<td> <td>
@Model.SoundSynths[i].SoundSynth.Type @soundByMachine.SoundSynth.Type
</td> </td>
</tr> </tr>
} }
@@ -666,18 +667,14 @@
</div> </div>
</td> </td>
} }
}
else
{
<td>Unknown data</td>
}
</tr> </tr>
counter++;
} }
</table> </table>
</td> </td>
</tr> </tr>
} }
@if(Model.Storage != null && Model.Storage.Length > 0) @if(Model.Storage.Count > 0)
{ {
<tr> <tr>
<th scope=row> <th scope=row>