Mango.Nop.Libraries/Mango.Nop.Core/Dtos/MgGenericAttributeDto.cs

55 lines
1.7 KiB
C#

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