feat(dal,templateUpdater): Сохранение шаблонов для переименования в таблицу TemplateRenamePending
This commit is contained in:
@@ -8,6 +8,7 @@ using PARR.Core.Repositories.Interfaces.JobRepositories;
|
||||
using PARR.Core.Repositories.Interfaces.RobotRepositories;
|
||||
using PARR.Core.Repositories.Interfaces.Schedule;
|
||||
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
||||
using PARR.Core.Repositories.Interfaces.TemplateRepositories;
|
||||
using PARR.Core.Repositories.Interfaces.Unit;
|
||||
using PARR.DAL.Configurations.DbSettings;
|
||||
using PARR.DAL.Context;
|
||||
@@ -18,6 +19,7 @@ using PARR.DAL.Repositories.JobRepositories;
|
||||
using PARR.DAL.Repositories.RobotRepositories;
|
||||
using PARR.DAL.Repositories.Schedule;
|
||||
using PARR.DAL.Repositories.TaskRepositories;
|
||||
using PARR.DAL.Repositories.TemplateRepositories;
|
||||
using PARR.DAL.Repositories.Unit;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
@@ -142,6 +144,12 @@ namespace PARR.DAL
|
||||
|
||||
#endregion
|
||||
|
||||
#region Templates
|
||||
|
||||
services.AddScoped<ITemplateRenamePendingRepository, TemplateRenamePendingRepository>();
|
||||
|
||||
#endregion
|
||||
|
||||
//services.AddTransient<INextRunModifierService, NextRunModifierService>();
|
||||
|
||||
#region NextRun Services
|
||||
|
||||
@@ -15,16 +15,6 @@ namespace PARR.DAL.Repositories.Base
|
||||
{
|
||||
internal abstract class BaseRepository<T> : IBaseRepository<T> where T : class, IBaseEntity
|
||||
{
|
||||
//private readonly ILogger<BaseRepository<T>> logger;
|
||||
|
||||
//protected abstract DbSet<T> EntitySet { get; }
|
||||
//protected abstract DataContext EntitiContext { get; }
|
||||
|
||||
//public BaseRepository(ILogger<BaseRepository<T>> logger)
|
||||
//{
|
||||
// this.logger = logger;
|
||||
//}
|
||||
|
||||
protected readonly ILogger logger;
|
||||
protected readonly DbSet<T> EntitySet;
|
||||
protected readonly DataContext EntityContext;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Core.Repositories.Interfaces.TemplateRepositories;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.Domain.Entities.TemplateEntities;
|
||||
|
||||
namespace PARR.DAL.Repositories.TemplateRepositories
|
||||
{
|
||||
internal class TemplateRenamePendingRepository : ITemplateRenamePendingRepository
|
||||
{
|
||||
private readonly DataContext _dataContext;
|
||||
private readonly ILogger<TemplateRenamePendingRepository> _logger;
|
||||
|
||||
public TemplateRenamePendingRepository(
|
||||
DataContext dataContext,
|
||||
ILogger<TemplateRenamePendingRepository> logger
|
||||
)
|
||||
{
|
||||
_dataContext = dataContext;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<TemplateRenamePending> Get()
|
||||
{
|
||||
return _dataContext.TemplateRenamePendings;
|
||||
}
|
||||
|
||||
public async Task<bool> CreateAsync(TemplateRenamePending obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _dataContext.TemplateRenamePendings.AddAsync(obj);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта типа TemplateRenamePending в БД");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user