mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move GPUs call to GpusService.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.1068</Version>
|
||||
<Version>3.0.99.1069</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
@@ -13,12 +13,22 @@ namespace Marechai.Services
|
||||
|
||||
public GpusService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<GpuViewModel>> GetAsync() => await _context.Gpus.Include(g => g.Company).OrderBy(g => g.Company.Name).ThenBy(g => g.Name).
|
||||
ThenBy(g => g.Introduced).Select(g => new GpuViewModel
|
||||
{
|
||||
Id = g.Id, Company = g.Company.Name,
|
||||
Introduced = g.Introduced,
|
||||
ModelCode = g.ModelCode, Name = g.Name
|
||||
}).ToListAsync();
|
||||
public async Task<List<GpuViewModel>> GetAsync() =>
|
||||
await _context.Gpus.OrderBy(g => g.Company.Name).ThenBy(g => g.Name).ThenBy(g => g.Introduced).
|
||||
Select(g => new GpuViewModel
|
||||
{
|
||||
Id = g.Id, Company = g.Company.Name, Introduced = g.Introduced, ModelCode = g.ModelCode,
|
||||
Name = g.Name
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<List<GpuViewModel>> GetByMachineAsync(int machineId) =>
|
||||
await _context.GpusByMachine.Where(g => g.MachineId == machineId).Select(g => g.Gpu).
|
||||
OrderBy(g => g.Company.Name).ThenBy(g => g.Name).Select(g => new GpuViewModel
|
||||
{
|
||||
Id = g.Id, Name = g.Name, Company = g.Company.Name, CompanyId = g.Company.Id,
|
||||
ModelCode = g.ModelCode, Introduced = g.Introduced, Package = g.Package,
|
||||
Process = g.Process, ProcessNm = g.ProcessNm, DieSize = g.DieSize,
|
||||
Transistors = g.Transistors
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,19 @@ namespace Marechai.Services
|
||||
public class MachinesService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly GpusService _gpusService;
|
||||
readonly IStringLocalizer<MachinesService> _l;
|
||||
readonly ProcessorsService _processorsService;
|
||||
readonly SoundSynthsService _soundSynthsService;
|
||||
readonly SoundSynthsService _soundSynthsService;
|
||||
|
||||
public MachinesService(MarechaiContext context, IStringLocalizer<MachinesService> localizer,
|
||||
ProcessorsService processorsService, SoundSynthsService soundSynthsService)
|
||||
GpusService gpusService, ProcessorsService processorsService,
|
||||
SoundSynthsService soundSynthsService)
|
||||
{
|
||||
_context = context;
|
||||
_l = localizer;
|
||||
_processorsService = processorsService;
|
||||
_context = context;
|
||||
_l = localizer;
|
||||
_gpusService = gpusService;
|
||||
_processorsService = processorsService;
|
||||
_soundSynthsService = soundSynthsService;
|
||||
}
|
||||
|
||||
@@ -70,14 +73,7 @@ namespace Marechai.Services
|
||||
model.FamilyId = family.Id;
|
||||
}
|
||||
|
||||
model.Gpus = await _context.GpusByMachine.Where(g => g.MachineId == machine.Id).Select(g => g.Gpu).
|
||||
Select(g => new GpuViewModel
|
||||
{
|
||||
Id = g.Id, Name = g.Name, Company = g.Company.Name,
|
||||
CompanyId = g.Company.Id, ModelCode = g.ModelCode,
|
||||
Introduced = g.Introduced, Package = g.Package, Process = g.Process,
|
||||
ProcessNm = g.ProcessNm, DieSize = g.DieSize, Transistors = g.Transistors
|
||||
}).ToListAsync();
|
||||
model.Gpus = await _gpusService.GetByMachineAsync(machine.Id);
|
||||
|
||||
model.Memory = await _context.MemoryByMachine.Where(m => m.MachineId == machine.Id).
|
||||
Select(m => new MemoryViewModel
|
||||
|
||||
Reference in New Issue
Block a user