Esempio n. 1
0
        public async Task <ActionResult <SettingDto[]> > GetList([FromQuery] String filter)
        {
            var myFilter = new SettingFilterDto();

            if (!string.IsNullOrWhiteSpace(filter))
            {
                myFilter = Newtonsoft.Json.JsonConvert.DeserializeObject <SettingFilterDto>(filter);
            }
            var res = await _service.GetList(myFilter);

            return(res);
        }
Esempio n. 2
0
        public async Task <SettingDto[]> GetList(SettingFilterDto filter)
        {
            IQueryable <Setting> query = _dbCtx.Settings;

            if (filter.Categories != null && filter.Categories.Length > 0)
            {
                var res = await query.ToArrayAsync();

                var mainRes = new List <SettingDto>();
                foreach (var category in filter.Categories)
                {
                    //query = query.Where(x => x.Key.StartsWith(category));
                    mainRes.AddRange(res.Where(x => x.Key.StartsWith(category)).Select(x => x.ToDto()));
                }
                return(mainRes.ToArray());
            }

            var result = await query.ToArrayAsync();

            return(result.Select(x => x.ToDto()).ToArray());
        }