mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Optimize view of sound synthetizers admin page.
This commit is contained in:
@@ -54,7 +54,16 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
IIncludableQueryable<SoundSynth, Company> cicmContext = _context.SoundSynths.Include(s => s.Company);
|
||||
return View(await cicmContext.ToListAsync());
|
||||
return View(await cicmContext.OrderBy(s => s.Company).ThenBy(s => s.Name).ThenBy(s => s.ModelCode)
|
||||
.Select(s => new SoundSynthViewModel
|
||||
{
|
||||
Company = s.Company.Name,
|
||||
Id = s.Id,
|
||||
Introduced = s.Introduced,
|
||||
ModelCode = s.ModelCode,
|
||||
Name = s.Name,
|
||||
Type = s.Type
|
||||
}).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Admin/SoundSynths/Details/5
|
||||
|
||||
56
cicm_web/Areas/Admin/Models/SoundSynthViewModel.cs
Normal file
56
cicm_web/Areas/Admin/Models/SoundSynthViewModel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : SoundSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Describes chips that generate sound.
|
||||
//
|
||||
// --[ 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;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class SoundSynthViewModel
|
||||
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public string Name { get; set; }
|
||||
[DisplayName("Model code")]
|
||||
public string ModelCode { get; set; }
|
||||
[DisplayFormat(DataFormatString = "{0:d}")]
|
||||
[DataType(DataType.Date)]
|
||||
public DateTime? Introduced { get; set; }
|
||||
public int? Type { get; set; }
|
||||
|
||||
public string Company { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
*******************************************************************************/
|
||||
}
|
||||
@using Cicm.Database.Models
|
||||
@model IEnumerable<Cicm.Database.Models.SoundSynth>
|
||||
@model IEnumerable<Cicm.Database.Models.SoundSynthViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Sound synthetizers (Admin)";
|
||||
@@ -66,11 +66,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(SoundSynth item in Model)
|
||||
@foreach(SoundSynthViewModel item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Name)
|
||||
@Html.DisplayFor(modelItem => item.Company)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.542</Version>
|
||||
<Version>3.0.99.543</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user