Вроде все ошибки устранил. не запускал.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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 ApplicationInHostService : BaseService<ApplicationInHost>, IApplicationInHostService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationInHostService> logger;
|
||||
|
||||
public ApplicationInHostService(DataContext dataContext, ILogger<ApplicationInHostService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
30
PARR.DAL/Services/Implementations/ApplicationService.cs
Normal file
30
PARR.DAL/Services/Implementations/ApplicationService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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 ApplicationService : BaseService<Application>, IApplicationService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationService> logger;
|
||||
|
||||
public ApplicationService(DataContext dataContext, ILogger<ApplicationService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<Application> EntitySet => dataContext.Applications;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public async Task<Application?> GetByNameAsync(string appName)
|
||||
{
|
||||
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
25
PARR.DAL/Services/Implementations/ApplicationTypeService.cs
Normal file
25
PARR.DAL/Services/Implementations/ApplicationTypeService.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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 ApplicationTypeService : BaseService<ApplicationType>, IApplicationTypeService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationTypeService> logger;
|
||||
|
||||
public ApplicationTypeService(DataContext dataContext, ILogger<ApplicationTypeService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<ApplicationType> EntitySet => dataContext.ApplicationTypes;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -21,21 +21,38 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public async Task<Host?> GetHostWithAppsAsync(string IP, string RegionalEK)//TODO
|
||||
public async Task<Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
|
||||
{
|
||||
try
|
||||
{
|
||||
var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
return host;
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
|
||||
return null;
|
||||
}
|
||||
|
||||
//try
|
||||
//{
|
||||
// var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
// return host;
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
|
||||
// return null;
|
||||
//}
|
||||
return await EntitySet
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||
.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
}
|
||||
|
||||
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)
|
||||
public async Task<Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK)
|
||||
{
|
||||
return await EntitySet
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||
.FirstOrDefaultAsync(h => h.IP == IP && h.LinkEK == linkEK && h.RegionalEK == regionalEK);
|
||||
}
|
||||
|
||||
|
||||
public async Task<Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK)
|
||||
{
|
||||
return await EntitySet.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
}
|
||||
|
||||
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationInHostService : IBaseService<ApplicationInHost>
|
||||
{
|
||||
}
|
||||
}
|
||||
10
PARR.DAL/Services/Interfaces/IApplicationService.cs
Normal file
10
PARR.DAL/Services/Interfaces/IApplicationService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationService : IBaseService<Application>
|
||||
{
|
||||
Task<Application?> GetByNameAsync(string appName);
|
||||
}
|
||||
}
|
||||
9
PARR.DAL/Services/Interfaces/IApplicationTypeService.cs
Normal file
9
PARR.DAL/Services/Interfaces/IApplicationTypeService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationTypeService : IBaseService<ApplicationType>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace PARR.DAL.Services.Interfaces
|
||||
public interface IHostService : IBaseService<Host>
|
||||
{
|
||||
Task<Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK);
|
||||
Task<Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK);
|
||||
//Task<Host?> GetHostByRegionalEKAsync(string LinkEK);
|
||||
//Task<bool> UpdateAsync(Host host);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user