using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using AyCode.Interfaces.Addresses;
using AyCode.Interfaces.Profiles;
using AyCode.Interfaces.Profiles.Dtos;
using AyCode.Interfaces.Users;
using AyCode.Interfaces.Users.Dtos;

namespace AyCode.Models.Users;

public abstract class AcUserModelDtoMinBase<TUserDtoMin, TProfileDto> : AcModelDtoBase, /*AcModelDtoBase<IAcUserDtoMinBase<TProfileDto>>,*/ IAcUserModelDtoMinBase
    where TUserDtoMin : class, IAcUserDtoMinBase
    //where TProfile : class, IAcProfileDtoBase
    where TProfileDto : class, IAcProfileDtoBase
    //where TAddress : class, IAcAddress
{
    public TUserDtoMin UserDto { get; set;}
    public TProfileDto ProfileDto { get; set; }

    protected AcUserModelDtoMinBase() {}
    protected AcUserModelDtoMinBase(IAcUserDtoMinBase<TProfileDto> user) : base(user.Id)
    {
        Id = user.Id;

        UserDto = Activator.CreateInstance<TUserDtoMin>();
        UserDto.Id = user.Id;
        UserDto.AffiliateId = user.AffiliateId;

        ProfileDto = Activator.CreateInstance<TProfileDto>();
        ProfileDto.Id = user.Profile.Id;        
        ProfileDto.Name = user.Profile.Name;
        ProfileDto.FirstName = user.Profile.FirstName;
        ProfileDto.LastName = user.Profile.LastName;
        //Profile.NickName = user.Profile.NickName;
    }

    public void CopyUserDtoValuesToUser(IAcUserDtoMinBase<TProfileDto> user)
    {
        user.Id = UserDto.Id;
        user.AffiliateId = UserDto.AffiliateId;
    }

    //public virtual TUserDtoMin CreateMainEntity()
    //{
    //    var user = base.CreateMainEntity();

    //    user.AffiliateId = UserDto.AffiliateId;
    //    user.ProfileId = ProfileDto.Id;

    //    user.Profile = Activator.CreateInstance<>()

    //}
}