Implement page for listing screens.

This commit is contained in:
2019-06-01 23:48:54 +01:00
parent 2022dc0080
commit 366e27917c
6 changed files with 44 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,14 +8,18 @@ namespace Cicm.Database.Models
public class Screen : BaseModel<int>
{
[Range(1, 131072)]
[DisplayName("Width (mm)")]
public double? Width { get; set; }
[Range(1, 131072)]
[DisplayName("Height (mm)")]
public double? Height { get; set; }
[Required]
[DisplayName("Diagonal (inches)")]
public double Diagonal { get; set; }
[Required]
public virtual Resolution NativeResolution { get; set; }
[Range(2, 281474976710656)]
[DisplayName("Effective colors")]
public long? EffectiveColors { get; set; }
[Required]
public string Type { get; set; }
@@ -22,6 +27,17 @@ namespace Cicm.Database.Models
[NotMapped]
public long? Colors => EffectiveColors ?? NativeResolution.Colors;
[NotMapped]
public string Size
{
get
{
if(Width != null && Height != null) return $"{Width}x{Height} mm";
return "Unknown";
}
}
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
public virtual ICollection<ScreensByMachine> ScreensByMachines { get; set; }
}

View File

@@ -19,7 +19,9 @@ namespace cicm_web.Areas.Admin.Controllers
}
// GET: Screens
public async Task<IActionResult> Index() => View(await _context.Screens.ToListAsync());
public async Task<IActionResult> Index() =>
View(await _context.Screens.OrderBy(s => s.Diagonal).ThenBy(s => s.EffectiveColors).ThenBy(s => s.Type)
.ThenBy(s => s.Size).ToListAsync());
// GET: Screens/Details/5
public async Task<IActionResult> Details(int? id)

View File

@@ -55,6 +55,9 @@
<a asp-controller="Processors">Processors</a><br />
<a asp-controller="Resolutions">Resolutions</a><br />
<a asp-controller="ResolutionsByGpu">Resolutions by GPU</a><br />
<a asp-controller="ResolutionsByScreen">Resolutions by screen</a><br />
<a asp-controller="Screens">Screens</a><br />
<a asp-controller="ScreensByMachine">Screens by machine</a><br />
<a asp-controller="SoundSynths">Sound synthetizers</a><br />
<a asp-controller="SoundByMachine">Sound synthetizers by machine</a><br />
<a asp-controller="StorageByMachines">Storage by machines</a><br />

View File

@@ -5,23 +5,23 @@
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<h1>Screens</h1>
<p>
<a asp-action="Create">Create New</a>
<a asp-action="Create"
class="btn btn-primary">
Create New
</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Width)
</th>
<th>
@Html.DisplayNameFor(model => model.Height)
</th>
<th>
@Html.DisplayNameFor(model => model.Diagonal)
</th>
<th>
@Html.DisplayNameFor(model => model.Size)
</th>
<th>
@Html.DisplayNameFor(model => model.EffectiveColors)
</th>
@@ -35,15 +35,12 @@
@foreach(Screen item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Width)
</td>
<td>
@Html.DisplayFor(modelItem => item.Height)
</td>
<td>
@Html.DisplayFor(modelItem => item.Diagonal)
</td>
<td>
@Html.DisplayFor(modelItem => item.Size)
</td>
<td>
@Html.DisplayFor(modelItem => item.EffectiveColors)
</td>
@@ -51,16 +48,19 @@
@Html.DisplayFor(modelItem => item.Type)
</td>
<td>
<a asp-action="Edit"
asp-route-id="@item.Id">
Edit
</a> |
<a asp-action="Details"
asp-route-id="@item.Id">
asp-route-id="@item.Id"
class="btn btn-primary">
Details
</a> |
</a>
<a asp-action="Edit"
asp-route-id="@item.Id"
class="btn btn-secondary">
Edit
</a>
<a asp-action="Delete"
asp-route-id="@item.Id">
asp-route-id="@item.Id"
class="btn btn-danger">
Delete
</a>
</td>

View File

@@ -4,8 +4,5 @@
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"cicmContext": "Server=(localdb)\\mssqllocaldb;Database=cicmContext-3ead5ce4-a116-44e6-a347-9791facb4ffc;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

View File

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