using System.ComponentModel.DataAnnotations.Schema;
using Claim = System.Security.Claims.Claim;

namespace OpenWarehouse.warehouse.api.Data;

public class ClaimBase
{
    [Required]
    public string? ClaimType { get; set; }
    [Required]
    public string? ClaimValue { get; set; }
    public string? ClaimIssuer { get; set; }


    [NotMapped]
    public Claim Claim {
        get
        {
            return new Claim(ClaimType ?? throw new Exception("Null exemption")
                , ClaimValue ?? throw new Exception("Null exemption")
                , ClaimIssuer ?? "Local");
        }
        set
        {
            ClaimType = value.Type;
            ClaimValue = value.Value;
            ClaimIssuer = value.Issuer;
        }
    }
}