using AyCode.Interfaces;
using AyCode.Interfaces.Entities;

namespace AyCode.Models;

public abstract class AcModelDtoBase : IAcModelDtoBase
{
    public Guid Id { get; set; }

    protected AcModelDtoBase(){}
    protected AcModelDtoBase(Guid id) => Id = id;
}

public abstract class AcModelDtoBase<TMainEntity> : AcModelDtoBase, IAcModelDtoBase<TMainEntity> where TMainEntity : IEntityGuid
{
    protected AcModelDtoBase() : base() { }
    protected AcModelDtoBase(Guid id) : base(id) { }
    protected AcModelDtoBase(TMainEntity mainEntity) : this(mainEntity.Id) { }
    
    public virtual TMainEntity CreateMainEntity()
    {
        var mainEntity = Activator.CreateInstance<TMainEntity>();
        mainEntity.Id = Id;

        return mainEntity;
    }
}