45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using PARR.DAL.Context;
|
|
using PARR.DAL.Models;
|
|
using PARR.DAL.Services.Abstracts;
|
|
using PARR.DAL.Services.Interfaces;
|
|
|
|
namespace PARR.DAL.Services.Implementations
|
|
{
|
|
internal class TemplateService : BaseService<Template>, ITemplateService
|
|
{
|
|
private readonly DataContext dataContext;
|
|
private readonly ILogger<TemplateService> logger;
|
|
|
|
protected override DbSet<Template> EntitySet => dataContext.Templates;
|
|
|
|
protected override DataContext EntitiContext => dataContext;
|
|
|
|
public TemplateService(DataContext dataContext, ILogger<TemplateService> logger) : base(logger)
|
|
{
|
|
this.dataContext = dataContext;
|
|
this.logger = logger;
|
|
}
|
|
|
|
public async Task<Template?> GetTemplateByNameAsync(string name)
|
|
{
|
|
return await GetWithIncludes().FirstOrDefaultAsync(t => t.Name == name);
|
|
}
|
|
|
|
public IQueryable<Template> GetWithIncludes()
|
|
{
|
|
return Get()
|
|
.Include(h => h.Host)
|
|
.ThenInclude(t => t!.ResponseArea)
|
|
.Include(h => h.Host)
|
|
.ThenInclude(t => t!.EkStatus)
|
|
.Include(a => a.ApplicationsInWork)
|
|
.ThenInclude(w => w!.Work)
|
|
.ThenInclude(t => t!.Tnk)
|
|
.ThenInclude(s => s!.Subprocess)
|
|
.ThenInclude(p => p!.Process);
|
|
}
|
|
}
|
|
}
|