using System.Collections.Generic;
using Sockeye.Models;
using Sockeye.Biz;
namespace Sockeye.DataList
{
    internal class ReminderDataList : DataListProcessingBase, IDataListInternalCriteria
    {
        public ReminderDataList(long translationId)
        {
            DefaultListAType = SockType.Reminder;
            SQLFrom = "from areminder";
            var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
            AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
            DefaultColumns = new List<string>() { "ReminderName", "ReminderNotes", "ReminderStartDate", "ReminderStopDate" };
            DefaultSortBy = new Dictionary<string, string>() { { "ReminderStartDate", "-" } };
            FieldDefinitions = new List<DataListFieldDefinition>();

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ReminderName",
                FieldKey = "ReminderName",
                SockType = (int)SockType.Reminder,
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlIdColumnName = "areminder.id",
                SqlValueColumnName = "areminder.name",
                SqlColorColumnName = "areminder.color",
                IsRowId = true
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ReminderNotes",
                FieldKey = "ReminderNotes",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "areminder.notes"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ReminderStartDate",
                FieldKey = "ReminderStartDate",
                UiFieldDataType = (int)UiFieldDataType.DateTime,
                SqlValueColumnName = "areminder.startdate"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ReminderStopDate",
                FieldKey = "ReminderStopDate",
                UiFieldDataType = (int)UiFieldDataType.DateTime,
                SqlValueColumnName = "areminder.stopdate"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "Tags",
                FieldKey = "ReminderTags",
                UiFieldDataType = (int)UiFieldDataType.Tags,
                SqlValueColumnName = "areminder.tags"
            });

            //META column 
            FieldDefinitions.Add(new DataListFieldDefinition
            {
                FieldKey = "metareminderuser",
                UiFieldDataType = (int)UiFieldDataType.InternalId,
                SqlIdColumnName = "areminder.userid",
                SqlValueColumnName = "areminder.userid",
                IsMeta = true
            });

            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom1", FieldKey = "ReminderCustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom2", FieldKey = "ReminderCustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom3", FieldKey = "ReminderCustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom4", FieldKey = "ReminderCustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom5", FieldKey = "ReminderCustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom6", FieldKey = "ReminderCustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom7", FieldKey = "ReminderCustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom8", FieldKey = "ReminderCustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom9", FieldKey = "ReminderCustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom10", FieldKey = "ReminderCustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom11", FieldKey = "ReminderCustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom12", FieldKey = "ReminderCustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom13", FieldKey = "ReminderCustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom14", FieldKey = "ReminderCustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom15", FieldKey = "ReminderCustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
            FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom16", FieldKey = "ReminderCustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" });
        }

        //Ensure only current user can fetch their reminders
        public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
        {
            List<DataListFilterOption> ret = new List<DataListFilterOption>();

            DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metareminderuser" };
            FilterOption.Items.Add(new DataListColumnFilter() { value = currentUserId.ToString(), op = DataListFilterComparisonOperator.Equality });

            ret.Add(FilterOption);
            return ret;
        }

    }//eoc
}//eons