diff --git a/Mango.Nop.Core/Dtos/CustomerDto.cs b/Mango.Nop.Core/Dtos/CustomerDto.cs index fa47686..8888248 100644 --- a/Mango.Nop.Core/Dtos/CustomerDto.cs +++ b/Mango.Nop.Core/Dtos/CustomerDto.cs @@ -12,6 +12,7 @@ public class CustomerDto : ModelDtoBase, ISoftDeletedEntity public string FullName => $"{LastName} {FirstName}"; + public int RegisteredInStoreId { get; set; } public bool Deleted { get; set; } public CustomerDto() :base() @@ -31,6 +32,7 @@ public class CustomerDto : ModelDtoBase, ISoftDeletedEntity entity.FirstName = FirstName; entity.LastName = LastName; entity.Email = Email; + entity.RegisteredInStoreId = RegisteredInStoreId; entity.Deleted = Deleted; } @@ -43,6 +45,7 @@ public class CustomerDto : ModelDtoBase, ISoftDeletedEntity FirstName = entity.FirstName; LastName = entity.LastName; Email = entity.Email; + RegisteredInStoreId = entity.RegisteredInStoreId; Deleted = entity.Deleted; } diff --git a/Mango.Nop.Core/Dtos/MgGenericAttributeDto.cs b/Mango.Nop.Core/Dtos/MgGenericAttributeDto.cs new file mode 100644 index 0000000..1b636d7 --- /dev/null +++ b/Mango.Nop.Core/Dtos/MgGenericAttributeDto.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AyCode.Interfaces.Entities; +using Nop.Core.Domain.Common; + +namespace Mango.Nop.Core.Dtos +{ + public interface IGenericAttributeDto : IModelDtoBase + { + public int EntityId { get; set; } + public string KeyGroup { get; set; } + public string Key { get; set; } + public string Value { get; set; } + public int StoreId { get; set; } + public DateTime? CreatedOrUpdatedDateUTC { get; set; } + } + + public abstract class MgGenericAttributeDto : GenericAttribute, IGenericAttributeDto + { + public GenericAttribute CreateMainEntity() + { + var mainEntity = Activator.CreateInstance(); + CopyDtoValuesToEntity(mainEntity); + + mainEntity.CreatedOrUpdatedDateUTC = DateTime.UtcNow; + return mainEntity; + } + + public void CopyDtoValuesToEntity(GenericAttribute entity) + { + entity.Id = Id; + entity.Key = Key; + entity.Value = Value; + entity.EntityId = EntityId; + entity.KeyGroup = KeyGroup; + entity.StoreId = StoreId; + entity.CreatedOrUpdatedDateUTC = CreatedOrUpdatedDateUTC; + } + + public void CopyEntityValuesToDto(GenericAttribute entity) + { + Id = entity.Id; + Key = entity.Key; + Value = entity.Value; + EntityId = entity.EntityId; + KeyGroup = entity.KeyGroup; + StoreId = entity.StoreId; + CreatedOrUpdatedDateUTC = entity.CreatedOrUpdatedDateUTC; + } + } +} diff --git a/Mango.Nop.Core/Extensions/GenericAttributeExtensions.cs b/Mango.Nop.Core/Extensions/GenericAttributeExtensions.cs index beebc44..652fba2 100644 --- a/Mango.Nop.Core/Extensions/GenericAttributeExtensions.cs +++ b/Mango.Nop.Core/Extensions/GenericAttributeExtensions.cs @@ -1,7 +1,10 @@ -using AyCode.Utils.Extensions; +using System; +using System.Collections.Generic; +using AyCode.Utils.Extensions; using Mango.Nop.Core.Utils; using Nop.Core.Domain.Common; using System.Diagnostics.CodeAnalysis; +using System.Linq; namespace Mango.Nop.Core.Extensions; @@ -31,4 +34,20 @@ public static class GenericAttributeExtensions value = CommonHelper2.To(gaValue); return true; } + + public static GenericAttribute AddNewGenericAttribute(this ICollection src, string keyGroup, string key, string value, int entityId, int storeId) + { + var ga = new GenericAttribute + { + KeyGroup = keyGroup, + Key = key, + Value = value, + EntityId = entityId, + StoreId = storeId, + CreatedOrUpdatedDateUTC = DateTime.UtcNow + }; + + src.Add(ga); + return ga; + } } \ No newline at end of file diff --git a/Mango.Nop.Core/Interfaces/ForeignKeys/ICustomerForeignKey.cs b/Mango.Nop.Core/Interfaces/ForeignKeys/ICustomerForeignKey.cs new file mode 100644 index 0000000..1a0144f --- /dev/null +++ b/Mango.Nop.Core/Interfaces/ForeignKeys/ICustomerForeignKey.cs @@ -0,0 +1,9 @@ +using AyCode.Core.Interfaces; +using AyCode.Interfaces; + +namespace Mango.Nop.Core.Interfaces.ForeignKeys; + +public interface ICustomerForeignKey : IForeignKey +{ + int CustomerId { get; set; } +} \ No newline at end of file diff --git a/Mango.Nop.Core/Interfaces/ForeignKeys/IGenericAttributeForeignCollection.cs b/Mango.Nop.Core/Interfaces/ForeignKeys/IGenericAttributeForeignCollection.cs new file mode 100644 index 0000000..480dcba --- /dev/null +++ b/Mango.Nop.Core/Interfaces/ForeignKeys/IGenericAttributeForeignCollection.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using AyCode.Core.Interfaces; +using Nop.Core.Domain.Common; + +namespace Mango.Nop.Core.Interfaces.ForeignKeys; + +public interface IGenericAttributeForeignList : IGenericAttributeForeignCollection> +{ +} + +public interface IGenericAttributeForeignCollection : IForeignCollection where T : IEnumerable +{ + T GenericAttributes { get; } +} \ No newline at end of file