DeactivateTemplates
This commit is contained in:
34
PARR.GeneratorTemplates/Services/ValidatorService.cs
Normal file
34
PARR.GeneratorTemplates/Services/ValidatorService.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.GeneratorTemplates.Services
|
||||
{
|
||||
internal class ValidatorService : IValidatorService
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public ValidatorService(IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка, валидны ли поля и связана ли Работа с Приложением
|
||||
/// </summary>
|
||||
/// <param name="applicationId"></param>
|
||||
/// <param name="workId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> IsValidApplicationAndWorksAsync(Guid applicationId, Guid workId)
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var service = scope.ServiceProvider.GetService<IApplicationsInWorkService>();
|
||||
|
||||
if (service == null)
|
||||
throw new Exception($"Не найден сервис: {nameof(IApplicationsInWorkService)}");
|
||||
|
||||
return await service.Get(applicationId, workId) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user