using System.Collections.Generic;
using System.Linq;
using Sockeye.Biz;
using Sockeye.Models;

namespace Sockeye.DataList
{
    internal class TrialLicenseRequestDataList : DataListProcessingBase
    {
        public TrialLicenseRequestDataList(long translationId)
        {
            DefaultListAType = SockType.TrialLicenseRequest;
            SQLFrom = @"FROM atriallicenserequest ";

            var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
            AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
            DefaultColumns = new List<string>() { "id", "TrialLicenseRequestCompanyName", "TrialLicenseRequestRequested", "TrialLicenseRequestStatus", "TrialLicenseRequestFetchedOn" };
            DefaultSortBy = new Dictionary<string, string>() { { "id", "-" } };
            FieldDefinitions = new List<DataListFieldDefinition>();
            /*
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequest', 'Trial license request' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestList', 'Trial license requests' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestCompanyName', 'Company' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestContactName', 'Contact' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestEmail', 'Email address' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestEmailValidated', 'Email validated' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRequested', 'Requested' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestProcessed', 'Processed' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestStatus', 'Status' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestRejectReason', 'Reject reason' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestFetchedOn', 'Fetched' FROM atranslation t  where t.baselanguage = 'en'");
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'TrialLicenseRequestPerpetual', 'Perpetual' FROM atranslation t  where t.baselanguage = 'en'");
"CREATE TABLE atriallicenserequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid TEXT NOT NULL, companyname TEXT NOT NULL, "
+ "contactname TEXT NOT NULL, email TEXT NOT NULL, emailconfirmcode TEXT NOT NULL, emailvalidated BOOL DEFAULT false, "
+ "requested TIMESTAMPTZ NOT NULL, processed TIMESTAMPTZ, status INTEGER NOT NULL DEFAULT 0, rejectreason TEXT, key TEXT, "
+ "fetchedon TIMESTAMPTZ, perpetual BOOL DEFAULT false NOT NULL )"
            */

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ID",
                FieldKey = "id",
                SockType = (int)SockType.TrialLicenseRequest,
                UiFieldDataType = (int)UiFieldDataType.Integer,
                SqlIdColumnName = "atriallicenserequest.id",
                SqlValueColumnName = "atriallicenserequest.id",
                IsRowId = true
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "DatabaseID",
                FieldKey = "DatabaseID",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "atriallicenserequest.dbid"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestCompanyName",
                FieldKey = "TrialLicenseRequestCompanyName",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "atriallicenserequest.companyname"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestContactName",
                FieldKey = "TrialLicenseRequestContactName",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "atriallicenserequest.contactname"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestEmail",
                FieldKey = "TrialLicenseRequestEmail",
                UiFieldDataType = (int)UiFieldDataType.EmailAddress,
                SqlValueColumnName = "atriallicenserequest.email"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestRequested",
                FieldKey = "TrialLicenseRequestRequested",
                UiFieldDataType = (int)UiFieldDataType.DateTime,
                SqlValueColumnName = "atriallicenserequest.requested"
            });


            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestProcessed",
                FieldKey = "TrialLicenseRequestProcessed",
                UiFieldDataType = (int)UiFieldDataType.DateTime,
                SqlValueColumnName = "atriallicenserequest.processed"
            });


            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestStatus",
                FieldKey = "TrialLicenseRequestStatus",
                UiFieldDataType = (int)UiFieldDataType.Enum,
                EnumType = Sockeye.Util.StringUtil.TrimTypeName(typeof(TrialRequestStatus).ToString()),
                SqlValueColumnName = "atriallicenserequest.status"
            });


            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestRejectReason",
                FieldKey = "TrialLicenseRequestRejectReason",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "atriallicenserequest.rejectreason"
            });



            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestFetchedOn",
                FieldKey = "TrialLicenseRequestFetchedOn",
                UiFieldDataType = (int)UiFieldDataType.DateTime,
                SqlValueColumnName = "atriallicenserequest.fetchedon"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "TrialLicenseRequestPerpetual",
                FieldKey = "TrialLicenseRequestPerpetual",
                UiFieldDataType = (int)UiFieldDataType.Bool,
                SqlValueColumnName = "atriallicenserequest.perpetual"
            });


        }

    }//eoc
}//eons