mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move GPUs admin index to Blazor.
This commit is contained in:
24
Marechai/Services/GpusService.cs
Normal file
24
Marechai/Services/GpusService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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 GpusService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user