mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
24 lines
1.1 KiB
C#
24 lines
1.1 KiB
C#
|
|
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();
|
||
|
|
}
|
||
|
|
}
|