diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 9b2c99c3..9df04edc 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1067 + 3.0.99.1068 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website @@ -79,6 +79,9 @@ true + + true + <_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" /> diff --git a/Marechai/Pages/Admin/Index.razor b/Marechai/Pages/Admin/Index.razor index 39ab93fd..bb6908a5 100644 --- a/Marechai/Pages/Admin/Index.razor +++ b/Marechai/Pages/Admin/Index.razor @@ -77,6 +77,9 @@
  • @L["Screens"]
  • +
  • + @L["Sound synthesizers"] +
  • diff --git a/Marechai/Pages/Admin/SoundSynths.razor b/Marechai/Pages/Admin/SoundSynths.razor new file mode 100644 index 00000000..6deed92e --- /dev/null +++ b/Marechai/Pages/Admin/SoundSynths.razor @@ -0,0 +1,114 @@ +@{ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// ---------------------------------------------------------------------------- +// +// Filename : SoundSynths.razor +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// List of sound synthesizers +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2020 Natalia Portillo +*******************************************************************************/ +} + +@page "/admin/sound_synths" +@using Marechai.Database.Models +@inherits OwningComponentBase +@inject IStringLocalizer L +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

    @L["Sound synthesizers"]

    +@if (_soundSynths is null) +{ +

    @L["Loading..."]

    + + return; +} +

    + + @L["Create new"] + +

    + + + + + + + + + + + + + @foreach (var item in _soundSynths) + { + + + + + + + + + } + +
    + @L["Company"] + + @L["Name"] + + @L["Model code"] + + @L["Introduced"] + + @L["Type"] +
    + @item.CompanyName + + @item.Name + + @item.ModelCode + + @item.IntroducedView + + @item.Type + + + @L["Details"] + + + @L["Edit"] + + + @L["Delete"] + +
    + +@code +{ + List _soundSynths; + + protected override async Task OnInitializedAsync() + { + _soundSynths = await Service.GetAsync(); + } +} \ No newline at end of file diff --git a/Marechai/Resources/Services/AdminService.es.resx b/Marechai/Resources/Services/AdminService.es.resx index a49cedde..31cca8f1 100644 --- a/Marechai/Resources/Services/AdminService.es.resx +++ b/Marechai/Resources/Services/AdminService.es.resx @@ -202,4 +202,8 @@ Pantallas Screens. + + Sintetizadores de sonido + Sound synthesizers. + \ No newline at end of file diff --git a/Marechai/Resources/Services/SoundSynthsService.es.resx b/Marechai/Resources/Services/SoundSynthsService.es.resx new file mode 100644 index 00000000..78948431 --- /dev/null +++ b/Marechai/Resources/Services/SoundSynthsService.es.resx @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Sintetizadores de sonido + Sound synthesizers + + + Cargando... + Message that appears while data is being loaded from database + + + Nombre + Name + + + Compañía + Company + + + Modelo + Model + + + Introducido el + Introduced + + + Tipo + Type + + + Crear nuevo + Create new + + + Detalles + Details + + + Editar + Edit + + + Eliminar + Delete + + \ No newline at end of file diff --git a/Marechai/Services/MachinesService.cs b/Marechai/Services/MachinesService.cs index ce33f578..20aa70c3 100644 --- a/Marechai/Services/MachinesService.cs +++ b/Marechai/Services/MachinesService.cs @@ -13,13 +13,15 @@ namespace Marechai.Services readonly MarechaiContext _context; readonly IStringLocalizer _l; readonly ProcessorsService _processorsService; + readonly SoundSynthsService _soundSynthsService; public MachinesService(MarechaiContext context, IStringLocalizer localizer, - ProcessorsService processorsService) + ProcessorsService processorsService, SoundSynthsService soundSynthsService) { _context = context; _l = localizer; _processorsService = processorsService; + _soundSynthsService = soundSynthsService; } public async Task> GetAsync() => @@ -85,15 +87,7 @@ namespace Marechai.Services model.Processors = await _processorsService.GetByMachineAsync(machine.Id); - model.SoundSynthesizers = - await _context.SoundByMachine.Where(s => s.MachineId == machine.Id).Select(s => s.SoundSynth). - Select(s => new SoundSynthViewModel - { - Id = s.Id, Name = s.Name, CompanyId = s.Company.Id, CompanyName = s.Company.Name, - ModelCode = s.ModelCode, Introduced = s.Introduced, Voices = s.Voices, - Frequency = s.Frequency, Depth = s.Depth, SquareWave = s.SquareWave, - WhiteNoise = s.WhiteNoise, Type = s.Type - }).ToListAsync(); + model.SoundSynthesizers = await _soundSynthsService.GetByMachineAsync(machine.Id); model.Storage = await _context.StorageByMachine.Where(s => s.MachineId == machine.Id). Select(s => new StorageViewModel diff --git a/Marechai/Services/Register.cs b/Marechai/Services/Register.cs index 7fecc40a..ad051a62 100644 --- a/Marechai/Services/Register.cs +++ b/Marechai/Services/Register.cs @@ -58,6 +58,7 @@ namespace Marechai.Services services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } } } \ No newline at end of file diff --git a/Marechai/Services/SoundSynthsService.cs b/Marechai/Services/SoundSynthsService.cs new file mode 100644 index 00000000..567f8fc4 --- /dev/null +++ b/Marechai/Services/SoundSynthsService.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Database.Models; +using Marechai.ViewModels; +using Microsoft.EntityFrameworkCore; + +namespace Marechai.Services +{ + public class SoundSynthsService + { + readonly MarechaiContext _context; + + public SoundSynthsService(MarechaiContext context) => _context = context; + + public async Task> GetAsync() => + await _context.SoundSynths.OrderBy(s => s.Company.Name).ThenBy(s => s.Name).ThenBy(s => s.ModelCode). + Select(s => new SoundSynthViewModel + { + Id = s.Id, Name = s.Name, CompanyId = s.Company.Id, CompanyName = s.Company.Name, + ModelCode = s.ModelCode, Introduced = s.Introduced, Voices = s.Voices, + Frequency = s.Frequency, Depth = s.Depth, SquareWave = s.SquareWave, + WhiteNoise = s.WhiteNoise, Type = s.Type + }).ToListAsync(); + + public async Task> GetByMachineAsync(int machineId) => + await _context.SoundByMachine.Where(s => s.MachineId == machineId).Select(s => s.SoundSynth). + OrderBy(s => s.Company.Name).ThenBy(s => s.Name).ThenBy(s => s.ModelCode). + Select(s => new SoundSynthViewModel + { + Id = s.Id, Name = s.Name, CompanyId = s.Company.Id, CompanyName = s.Company.Name, + ModelCode = s.ModelCode, Introduced = s.Introduced, Voices = s.Voices, + Frequency = s.Frequency, Depth = s.Depth, SquareWave = s.SquareWave, + WhiteNoise = s.WhiteNoise, Type = s.Type + }).ToListAsync(); + } +} \ No newline at end of file diff --git a/Marechai/ViewModels/SoundSynthViewModel.cs b/Marechai/ViewModels/SoundSynthViewModel.cs index 4e49af41..2713cd7b 100644 --- a/Marechai/ViewModels/SoundSynthViewModel.cs +++ b/Marechai/ViewModels/SoundSynthViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; namespace Marechai.ViewModels { @@ -15,5 +16,8 @@ namespace Marechai.ViewModels public int? SquareWave { get; set; } public int? WhiteNoise { get; set; } public int? Type { get; set; } + + [NotMapped] + public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown"; } } \ No newline at end of file