using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Domain.Entities.Members;

namespace Domain.Entities.Donations;

public class SettlementAccount
{
    [ForeignKey(nameof(ChannelID))]
    public virtual Channel? Channel { get; private set; }

    [ForeignKey(nameof(MemberID))]
    public virtual Member? Member { get; private set; }

    [Key]
    public int ID { get; private set; }

    public int ChannelID { get; private set; }

    public int MemberID { get; private set; }

    public string BankCode { get; private set; } = default!;

    public string BankName { get; private set; } = default!;

    public string AccountNumber { get; private set; } = default!;

    public string AccountHolder { get; private set; } = default!;

    public bool IsVerified { get; private set; }

    public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;

    public DateTime UpdatedAt { get; private set; } = DateTime.UtcNow;

    private SettlementAccount() { }

    public static SettlementAccount Create(
        int channelID,
        int memberID,
        string bankCode,
        string bankName,
        string accountNumber,
        string accountHolder
    ) {
        return new SettlementAccount
        {
            ChannelID = channelID,
            MemberID = memberID,
            BankCode = bankCode,
            BankName = bankName,
            AccountNumber = accountNumber,
            AccountHolder = accountHolder,
            IsVerified = true
        };
    }

    public void Update(string bankCode, string bankName, string accountNumber, string accountHolder)
    {
        BankCode = bankCode;
        BankName = bankName;
        AccountNumber = accountNumber;
        AccountHolder = accountHolder;
        IsVerified = true;
        UpdatedAt = DateTime.UtcNow;
    }
}