From 38ec5c475e567b5a839b352dff40c8b915a6747d Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 15 Nov 2024 15:15:56 +0100 Subject: [PATCH] improvements --- .../{EntityBase.cs => MgEntityBase.cs} | 2 +- ...RemoveEntity.cs => IMgSoftRemoveEntity.cs} | 2 +- ...EntityInt.cs => IMgSoftRemoveEntityInt.cs} | 2 +- Mango.Nop.Core/Repositories/MgDbTableBase.cs | 70 ++++++++++++++++++- 4 files changed, 70 insertions(+), 6 deletions(-) rename Mango.Nop.Core/Entities/{EntityBase.cs => MgEntityBase.cs} (64%) rename Mango.Nop.Core/Interfaces/{ISoftRemoveEntity.cs => IMgSoftRemoveEntity.cs} (68%) rename Mango.Nop.Core/Interfaces/{ISoftRemoveEntityInt.cs => IMgSoftRemoveEntityInt.cs} (62%) diff --git a/Mango.Nop.Core/Entities/EntityBase.cs b/Mango.Nop.Core/Entities/MgEntityBase.cs similarity index 64% rename from Mango.Nop.Core/Entities/EntityBase.cs rename to Mango.Nop.Core/Entities/MgEntityBase.cs index 1d34c1f..e5fc986 100644 --- a/Mango.Nop.Core/Entities/EntityBase.cs +++ b/Mango.Nop.Core/Entities/MgEntityBase.cs @@ -3,6 +3,6 @@ using Nop.Core; namespace Mango.Nop.Core.Entities; -public class EntityBase : BaseEntity, IEntityInt +public class MgEntityBase : BaseEntity, IEntityInt { } \ No newline at end of file diff --git a/Mango.Nop.Core/Interfaces/ISoftRemoveEntity.cs b/Mango.Nop.Core/Interfaces/IMgSoftRemoveEntity.cs similarity index 68% rename from Mango.Nop.Core/Interfaces/ISoftRemoveEntity.cs rename to Mango.Nop.Core/Interfaces/IMgSoftRemoveEntity.cs index c2463d8..f9be7a9 100644 --- a/Mango.Nop.Core/Interfaces/ISoftRemoveEntity.cs +++ b/Mango.Nop.Core/Interfaces/IMgSoftRemoveEntity.cs @@ -4,7 +4,7 @@ using Nop.Core.Domain.Common; namespace Mango.Nop.Core.Interfaces; // ReSharper disable once PossibleInterfaceMemberAmbiguity -public interface ISoftRemoveEntity : IAcSoftRemoveEntity, ISoftDeletedEntity +public interface IMgSoftRemoveEntity : IAcSoftRemoveEntity, ISoftDeletedEntity { } \ No newline at end of file diff --git a/Mango.Nop.Core/Interfaces/ISoftRemoveEntityInt.cs b/Mango.Nop.Core/Interfaces/IMgSoftRemoveEntityInt.cs similarity index 62% rename from Mango.Nop.Core/Interfaces/ISoftRemoveEntityInt.cs rename to Mango.Nop.Core/Interfaces/IMgSoftRemoveEntityInt.cs index cff43fa..70320ea 100644 --- a/Mango.Nop.Core/Interfaces/ISoftRemoveEntityInt.cs +++ b/Mango.Nop.Core/Interfaces/IMgSoftRemoveEntityInt.cs @@ -3,7 +3,7 @@ namespace Mango.Nop.Core.Interfaces; // ReSharper disable once PossibleInterfaceMemberAmbiguity -public interface ISoftRemoveEntityInt : IAcSoftRemoveEntityInt, ISoftRemoveEntity +public interface IMgSoftRemoveEntityInt : IAcSoftRemoveEntityInt, IMgSoftRemoveEntity { } \ No newline at end of file diff --git a/Mango.Nop.Core/Repositories/MgDbTableBase.cs b/Mango.Nop.Core/Repositories/MgDbTableBase.cs index ae5c14d..f2fd63c 100644 --- a/Mango.Nop.Core/Repositories/MgDbTableBase.cs +++ b/Mango.Nop.Core/Repositories/MgDbTableBase.cs @@ -1,4 +1,5 @@ -using Mango.Nop.Core.Interfaces; +using System.Linq.Expressions; +using Mango.Nop.Core.Interfaces; using Nop.Core; using Nop.Core.Caching; using Nop.Core.Configuration; @@ -7,9 +8,72 @@ using Nop.Data; namespace Mango.Nop.Core.Repositories; -public class MgDbTableBase: EntityRepository, IMgDbTableBase where TEntity : BaseEntity +public class MgDbTableBase(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) + : EntityRepository(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings), IMgDbTableBase where TEntity : BaseEntity { - public MgDbTableBase(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) + protected IEventPublisher EventPublisher = eventPublisher; + protected INopDataProvider DataProvider = dataProvider; + protected IShortTermCacheManager ShortTermCacheManager = shortTermCacheManager; + protected IStaticCacheManager StaticCacheManager = staticCacheManager; + + + public override void Update(TEntity entity, bool publishEvent = true) { + base.Update(entity, publishEvent); + } + + public override void Update(IList entities, bool publishEvent = true) + { + base.Update(entities, publishEvent); + } + + public override Task UpdateAsync(TEntity entity, bool publishEvent = true) + { + return base.UpdateAsync(entity, publishEvent); + } + + public override Task UpdateAsync(IList entities, bool publishEvent = true) + { + return base.UpdateAsync(entities, publishEvent); + } + + protected override Task DeleteAsync(IList entities) + { + return base.DeleteAsync(entities); + } + + protected override Task DeleteAsync(IList entities) + { + return base.DeleteAsync(entities); + } + + protected override IQueryable AddDeletedFilter(IQueryable query, in bool includeDeleted) + { + return base.AddDeletedFilter(query, in includeDeleted); + } + + public override Task DeleteAsync(TEntity entity, bool publishEvent = true) + { + return base.DeleteAsync(entity, publishEvent); + } + + public override Task DeleteAsync(IList entities, bool publishEvent = true) + { + return base.DeleteAsync(entities, publishEvent); + } + + public override Task DeleteAsync(Expression> predicate) + { + return base.DeleteAsync(predicate); + } + + public override void Delete(TEntity entity, bool publishEvent = true) + { + base.Delete(entity, publishEvent); + } + + public override int Delete(Expression> predicate) + { + return base.Delete(predicate); } } \ No newline at end of file