using System;
using System.Collections.Generic;
using AyaNova.Biz;


namespace AyaNova.Biz
{

    public class FilterOptions
    {
        public string Key { get; set; }
        public List<FilterField> Flds { get; set; }

        public FilterOptions(string key)
        {
            Flds = new List<FilterField>();
            Key = key;
        }

        public FilterOptions AddField(string FieldName, string LocaleKey, string DataType)
        {
            Flds.Add(new FilterField(FieldName, LocaleKey, DataType));
            return this;
        }

        internal void Localize(long userLocaleId)
        {
            List<string> keysRequired = new List<string>();
            foreach (FilterField f in Flds)
            {
                keysRequired.Add(f.Lt);
            }
            var trans = LocaleBiz.GetSubsetStatic(keysRequired, userLocaleId).Result;
            foreach (FilterField f in Flds)
            {
                f.Lt = trans[f.Lt];
            }
        }
    }

    public class FilterField
    {
        public string Fld { get; set; }
        public string Lt { get; set; }
        public string Type { get; set; }
        public FilterField(string fld, string lt, string type)
        {
            Fld = fld;
            Lt = lt;
            Type = type;

        }
    }
}
