using System.Collections.Generic; using System.Linq; namespace WeOnlineApp.Views.Shared.SearchForm { public class SearchFormViewModel { public SearchFormViewModel(List searchItems, string formId = "search-form", bool isSingle = false) { FormId = formId; SearchItems = searchItems.Select(SetDefault).ToList(); IsSingle = isSingle; } public bool IsSingle { get; set; } public string FormId { get; set; } public string Field { get; set; } public int FType { get; set; } public int EType { get; set; } public List SearchItems { get; set; } private SearchItem SetDefault(SearchItem item) { if (string.IsNullOrEmpty(item.FormId)) item.FormId = FormId; return item; } public SearchFormViewModel SetSearchOption(string field, FieldType fieldType = FieldType.I, ExpType expType = ExpType.Equal) { Field = field; FType = (int)fieldType; EType = (int)expType; return this; } } public enum FieldType { /// /// STRING /// S = 0, /// /// INT /// I = 1, /// /// INT /// In = 2, /// /// BOOL /// B = 3, /// /// BOOL /// Bn = 4, /// /// DATETIME /// D = 5, /// /// DATETIME? /// Dn = 6, /// /// long /// L = 7, /// /// long? /// Ln = 8, /// /// short /// Short = 9, /// /// Short? /// Sn = 10, /// /// float /// F = 11, /// /// float /// Fn = 12, /// /// Decimal /// Decimal = 13, /// /// Decimal /// DecimalNull = 14, /// /// Double /// Double = 15, /// /// Double /// DoubleNull = 16 } public enum ExpType { Equal , NotEqual , Greater , Less , GreaterOrEqual , LessOrEqual , Contains , NotContains } }