mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add code to upload machine photos as well as edit or view details about them.
This commit is contained in:
@@ -35,20 +35,14 @@ using Marechai.Database;
|
||||
using Marechai.Database.Models;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Marechai.Services
|
||||
{
|
||||
public class ComputersService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IStringLocalizer<ComputersService> _l;
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public ComputersService(MarechaiContext context, IStringLocalizer<ComputersService> localizer)
|
||||
{
|
||||
_context = context;
|
||||
_l = localizer;
|
||||
}
|
||||
public ComputersService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<int> GetComputersCountAsync() =>
|
||||
await _context.Machines.CountAsync(c => c.Type == MachineType.Computer);
|
||||
@@ -70,7 +64,7 @@ namespace Marechai.Services
|
||||
Where(m => m.Type == MachineType.Computer && EF.Functions.Like(m.Name, $"{c}%")).
|
||||
OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new MachineViewModel
|
||||
{
|
||||
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
|
||||
Id = m.Id, Name = m.Name, Company = m.Company.Name
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<List<MachineViewModel>> GetComputersByYearAsync(int year) =>
|
||||
@@ -79,14 +73,14 @@ namespace Marechai.Services
|
||||
m.Introduced.Value.Year == year).OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
|
||||
Select(m => new MachineViewModel
|
||||
{
|
||||
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
|
||||
Id = m.Id, Name = m.Name, Company = m.Company.Name
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<List<MachineViewModel>> GetComputersAsync() =>
|
||||
await _context.Machines.Include(m => m.Company).Where(m => m.Type == MachineType.Computer).
|
||||
OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new MachineViewModel
|
||||
{
|
||||
Id = m.Id, Name = m.Name, CompanyName = m.Company.Name
|
||||
Id = m.Id, Name = m.Name, Company = m.Company.Name
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user