using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace Sockeye.Models
{
    //https://stackoverflow.com/questions/46517584/how-to-add-a-parent-record-with-its-children-records-in-ef-core#46615455

    public class Integration
    {
        public long Id { get; set; }
        public uint Concurrency { get; set; }
        [Required]
        public Guid IntegrationAppId { get; set; } = Guid.Empty;//Guid of integrating application.  All data for it is stored under this guid key.  This guid should be fixed and unchanged for all users of the integration app, i.e. it shouldn't be unique to each install but unique to itself once, a publish app id
        [Required]
        public string Name { get; set; }
        public bool Active { get; set; }//integration apps should always check if this is true before working or not and give appropriate error if turned off
        public string IntegrationData { get; set; }//foreign object data store for entire integration, can be used for custom data, unused by any Sockeye add-on's, expect json or xml or some other text value here


        public List<IntegrationItem> Items { get; set; } = new List<IntegrationItem>();



    }//eoc

}//eons


// CREATE TABLE [dbo].[AINTEGRATION](
// [AID] [uniqueidentifier] NOT NULL,
// [ACREATED] [datetime] NULL,
// [AMODIFIED] [datetime] NULL,
// [ACREATOR] [uniqueidentifier] NULL,
// [AMODIFIER] [uniqueidentifier] NULL,
// [AACTIVE] [bit] NOT NULL, <--was set to true at creation of integration in plugins but never used beyond that, was intended to be able to temporarily pause an integration, maybe should enable it to work that way as intended
// [ANAME] [nvarchar](255) NOT NULL,
// [ALASTCONNECT] [datetime] NULL, <=---unused in v7 I'm dropping this as it's always going to be ambiguous and we don't use it anyway, let people put this in the integrationdata as json data in if they want to
// [AIOBJECT] [image] NULL, <--was not used don't bring forward as binary but do bring forward as a IntegrationData string where they can put json or whatever
// [AIOBJECTSIZE] [int] NULL, <- this one either
// [AAPPID] [uniqueidentifier] NOT NULL,
// [AAPPVERSION] [nvarchar](25) NOT NULL, <--unused, not keeping, if people need this they can use the intgrationdata and store as JSON with anything else they need
// [ASYNCCHECKPOINT] [nvarchar](255) NULL, <--unused, not keeping, if people need this they can use the intgrationdata and store as JSON with anything else they need