mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add resolutions service.
This commit is contained in:
27
Marechai/Services/ResolutionsService.cs
Normal file
27
Marechai/Services/ResolutionsService.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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 ResolutionsService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public ResolutionsService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<ResolutionViewModel>> GetAsync()
|
||||
{
|
||||
List<ResolutionViewModel> list = await _context.Resolutions.Select(r => new ResolutionViewModel
|
||||
{
|
||||
Id = r.Id, Width = r.Width, Height = r.Height, Colors = r.Colors,
|
||||
Palette = r.Palette, Chars = r.Chars, Grayscale = r.Grayscale
|
||||
}).ToListAsync();
|
||||
|
||||
return list.OrderBy(r => r.ToString()).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user