feat: создана структура проекта, core, domain, infrastructure. Перенесены enum и task согласно архитектуры
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.Base;
|
||||
using PARR.DAL.Models.Base.History.Base;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Entities.Base.History.Base;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PARR.DAL.Services.Abstracts
|
||||
{
|
||||
internal abstract class BaseService<T> : IBaseService<T> where T : class, IBase
|
||||
internal abstract class BaseService<T> : IBaseService<T> where T : class, IBaseEntity
|
||||
{
|
||||
private readonly ILogger<BaseService<T>> logger;
|
||||
|
||||
@@ -118,10 +118,10 @@ namespace PARR.DAL.Services.Abstracts
|
||||
/// <param name="obj"></param>
|
||||
private void DateModifiedResolver(EntityEntry obj)
|
||||
{
|
||||
if (obj.Entity is IBaseDateModified)
|
||||
if (obj.Entity is IBaseEntityDateModified)
|
||||
{
|
||||
logger.LogDebug("Обновляю DateModified для сущности типа {EntityType}", obj.Entity.GetType().Name);
|
||||
(obj.Entity as IBaseDateModified)!.DateModified = DateTimeOffset.UtcNow;
|
||||
(obj.Entity as IBaseEntityDateModified)!.DateModified = DateTimeOffset.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace PARR.DAL.Services.Abstracts
|
||||
FillHistoryProp(ref historyInstance, nameof(IHistoryTable.DateAddedToHistory), DateTimeOffset.UtcNow);
|
||||
|
||||
// Заполняем Id
|
||||
FillHistoryProp(ref historyInstance, nameof(IBase.Id), Guid.NewGuid());
|
||||
FillHistoryProp(ref historyInstance, nameof(IBaseEntity.Id), Guid.NewGuid());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -202,7 +202,7 @@ namespace PARR.DAL.Services.Abstracts
|
||||
return;
|
||||
|
||||
//Смотрим, если это Id, записываем его в ParentId
|
||||
var histPropName = prop.Name == nameof(IBase.Id) ? nameof(IHistoryTable.ParentId) : prop.Name;
|
||||
var histPropName = prop.Name == nameof(IBaseEntity.Id) ? nameof(IHistoryTable.ParentId) : prop.Name;
|
||||
|
||||
var histProp = historyInstance.GetType().GetProperty(histPropName);
|
||||
if (histProp == null) continue;
|
||||
|
||||
Reference in New Issue
Block a user