using System.Collections.Generic; using System.Web.Mvc; using WeOnlineApp.Views.Shared.SearchForm; namespace WeOnlineApp.Views.Shared.Query { public class QueryItem { public QueryItem(string key, string name, bool isSearch = false, bool isDisabled = false, bool isHidden = false, FieldType fieldType = FieldType.S, ExpType expType = ExpType.Contains, string formatter = "") { Key = key; Name = name; IsSearch = isSearch; IsDisabled = isDisabled; IsHidden = isHidden; FieldType = fieldType; ExpType = expType; Formatter = formatter; } public string Key { get; set; } public string Name { get; set; } public string Formatter { get; set; } public bool IsSearch { get; set; } public bool IsHidden { get; set; } public string HiddenStr => IsHidden ? "display:none;" : ""; public bool IsDisabled { get; set; } public string DisabledStr => IsDisabled ? "disable" : ""; public FieldType FieldType { get; set; } public ExpType ExpType { get; set; } public bool IsSelectTree { get; set; } public string SelectTreeClass => IsSelectTree ? " select2tree" : ""; public string SelectStr { get; set; } public QueryItem SetHidden() { IsHidden = true; return this; } public QueryItem SetDisabled() { IsDisabled = true; return this; } public QueryItem SetSelectStr(string str, bool isSelectTree = false) { IsSelectTree = isSelectTree; SelectStr = str; return this; } public QueryItem SetSelectStr(List list, bool isSelectTree = false) { IsSelectTree = isSelectTree; var str = ""; foreach (var item in list) { str += $""; } SelectStr = str; return this; } public QueryItem SetSelectStr(Dictionary dic, bool isSelectTree = false) { IsSelectTree = isSelectTree; if (dic.ContainsKey(Key)) { SelectStr = dic[Key]; } return this; } } }