Пример #1
0
        /// <summary>
        /// 获取枚举类型下拉框列表
        /// </summary>
        /// <returns></returns>
        public List <ComboBoxResponse> GetComboBoxList <T>() where T : Enum
        {
            Dictionary <object, string> data = Utils.GetEnumDict <T>();
            List <ComboBoxResponse>     list = new List <ComboBoxResponse>();

            foreach (var d in data)
            {
                ComboBoxResponse model = new ComboBoxResponse();
                model.Value = d.Key;
                model.Name  = d.Value;
                list.Add(model);
            }
            return(list);
        }
Пример #2
0
        /// <summary>
        /// 获取字典类型列表
        /// </summary>
        /// <returns></returns>
        public async Task <List <ComboBoxResponse> > GetCategorys()
        {
            using (_db)
            {
                List <Domain.Dictionary> data = await _db.Dictionary.AsNoTracking().Where(x => x.PId == null).ToListAsync();

                List <ComboBoxResponse> list = new List <ComboBoxResponse>();
                foreach (var d in data)
                {
                    ComboBoxResponse model = new ComboBoxResponse()
                    {
                        Value = d.Id.ToString(),
                        Name  = d.Name
                    };
                    list.Add(model);
                }
                return(list);
            }
        }