Esempio n. 1
0
        private List <SelectItem> GetCategory(string categoryCode, string search, bool notLike)
        {
            List <SelectItem> result = new List <SelectItem>();
            var query = BaseCodeService.GetItemsByCategory(categoryCode);

            if (!string.IsNullOrEmpty(search))
            {
                if (notLike)
                {
                    string[] values = search.Split(',');
                    query = query.Where(o => values.Contains(o.Key)).ToList();
                }
                else
                {
                    query = query.Where(o => o.Value.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1 || o.Key.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) > -1).ToList();
                }
            }
            else if (notLike)
            {
                return(result);
            }
            result = query.OrderBy(o => o.Value)
                     .Select(o => new SelectItem()
            {
                key = o.Key, value = o.Value
            })
                     .ToList();

            return(result);
        }
Esempio n. 2
0
        public JsonResult GetBaseCategory(string category)
        {
            var list = BaseCodeService.GetItemsByCategory(category);
            var data = list.Select(o => new { id = o.Key, text = o.Value }).ToList();

            return(Json(new JsonResultDataEntity <object>()
            {
                Code = 0, Data = data
            }));
        }