improvements, fixes

This commit is contained in:
Loretta 2025-11-26 09:42:07 +01:00
parent 6b09ba3d78
commit b21197ca67
5 changed files with 100 additions and 1 deletions

View File

@ -12,6 +12,7 @@ public class CustomerDto : ModelDtoBase<Customer>, 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<Customer>, ISoftDeletedEntity
entity.FirstName = FirstName;
entity.LastName = LastName;
entity.Email = Email;
entity.RegisteredInStoreId = RegisteredInStoreId;
entity.Deleted = Deleted;
}
@ -43,6 +45,7 @@ public class CustomerDto : ModelDtoBase<Customer>, ISoftDeletedEntity
FirstName = entity.FirstName;
LastName = entity.LastName;
Email = entity.Email;
RegisteredInStoreId = entity.RegisteredInStoreId;
Deleted = entity.Deleted;
}

View File

@ -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<GenericAttribute>
{
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<GenericAttribute>();
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;
}
}
}

View File

@ -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<TValue>(gaValue);
return true;
}
public static GenericAttribute AddNewGenericAttribute(this ICollection<GenericAttribute> 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;
}
}

View File

@ -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; }
}

View File

@ -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<List<GenericAttribute>>
{
}
public interface IGenericAttributeForeignCollection<T> : IForeignCollection<T> where T : IEnumerable<GenericAttribute>
{
T GenericAttributes { get; }
}