using System;
using System.Collections.Generic;
using Sockeye.Biz;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace Sockeye.Models
{
    //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, 
    //otherwise the server will call it an invalid record if the field isn't sent from client

    public class License : ICoreBizObjectModel
    {
        public long Id { get; set; }
        public uint Concurrency { get; set; }

        public DateTime Created { get; set; }
        public long CustomerId { get; set; }
        [NotMapped]
        public string CustomerViz { get; set; }
        public string RegTo { get; set; }
        public string Key { get; set; }
        public string FetchCode { get; set; }
        public string FetchEmail { get; set; }
        public DateTime? FetchedOn { get; set; }
        public string DbId { get; set; }
        public DateTime LicenseExpire { get; set; }
        public DateTime MaintenanceExpire { get; set; }

        public string Wiki { get; set; }
        public List<string> Tags { get; set; }

        //workaround for notification    
        [NotMapped, JsonIgnore]
        public string Name { get; set; }

        public License()
        {
            Tags = new List<string>();
        }

        [NotMapped, JsonIgnore]
        public SockType SType { get => SockType.License; }

    }//eoc

}//eons
/*
   await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMPTZ NOT NULL, "
                        + "customerid BIGINT NOT NULL REFERENCES acustomer(id), regto TEXT NOT NULL,  key TEXT NOT NULL, fetchcode TEXT, fetchemail TEXT, "
                        + "fetchedon TIMESTAMPTZ,  dbid TEXT, licenseexpire TIMESTAMPTZ, maintenanceexpire TIMESTAMPTZ NOT NULL, "
                        + "wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY )");
*/