Exemplo n.º 1
0
        public IActionResult finalList(int id)
        {
            ItemListFilterDto filter = new ItemListFilterDto();
//          var currentLevel = _context.CatalogRef.Where(cr => cr.Id == id).FirstOrDefault().LayerLevel;
            Dictionary <int?, string> myCategries = getCategoriesById(id);

            foreach (var category in myCategries)
            {
                if (category.Key == 1)
                {
                    filter.cat = category.Value;
                }
                if (category.Key == 2)
                {
                    filter.scat = category.Value;
                }
                if (category.Key == 3)
                {
                    filter.sscat = category.Value;
                }
            }

            //filter.cat = cat;
            //filter.scat = scat;
            //filter.sscat = sscat;

            List <Item> mylist = getItemList(filter);

            return(Ok(mylist));
        }
Exemplo n.º 2
0
        public List <Item> getItemList(ItemListFilterDto myFilter)
        {
            var items = _context.CodeRelations
                        .Where(cr => myFilter.cat != null ? cr.Cat == myFilter.cat : true)
                        .Where(cr => myFilter.scat != null ? cr.SCat == myFilter.scat : true)
                        .Where(cr => myFilter.sscat != null ? cr.SsCat == myFilter.sscat : true);

            var mylist = new List <Item>();

            foreach (var item in items)
            {
                Item ite = new Item();
                ite.code        = item.Code;
                ite.description = item.Name;
                ite.cat         = item.Cat;
                ite.scat        = item.SCat;
                ite.sscat       = item.SsCat;
                ite.price       = item.Price1;
                mylist.Add(ite);
            }

            return(mylist);
        }