2020-05-24 18:29:50 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-05-24 21:59:59 +01:00
|
|
|
using System.Threading.Tasks;
|
2020-05-24 18:29:50 +01:00
|
|
|
using Marechai.Database.Models;
|
|
|
|
|
|
|
|
|
|
namespace Marechai.Services
|
|
|
|
|
{
|
|
|
|
|
public class ScreensService
|
|
|
|
|
{
|
|
|
|
|
readonly MarechaiContext _context;
|
|
|
|
|
|
|
|
|
|
public ScreensService(MarechaiContext context) => _context = context;
|
|
|
|
|
|
|
|
|
|
public List<Screen> Get() => _context.Screens.AsEnumerable().OrderBy(s => s.Diagonal).
|
|
|
|
|
ThenBy(s => s.EffectiveColors).ThenBy(s => s.NativeResolution.ToString()).
|
|
|
|
|
ThenBy(s => s.Type).ThenBy(s => s.Size).ToList();
|
2020-05-24 21:59:59 +01:00
|
|
|
|
|
|
|
|
public async Task DeleteAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
Screen item = await _context.Screens.FindAsync(id);
|
|
|
|
|
|
|
|
|
|
if(item is null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_context.Screens.Remove(item);
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
}
|
2020-05-24 18:29:50 +01:00
|
|
|
}
|
|
|
|
|
}
|