Пример #1
0
        public void TestGetByBrand()
        {
            List <Item> baseItemList = new List <Item>()
            {
                _item3, _item4, _item5
            };
            List <Item> items = _testItemDb.GetByBrandOrDescription("not palindrome brand");

            Assert.True(AreEqualLists(items, baseItemList));
            Assert.Equal(3, items.Count);
        }
Пример #2
0
        public IActionResult SearchByDescriptionOrBrand(string searchParam)
        {
            List <Item>      itemList         = _itemDb.GetByBrandOrDescription(searchParam);
            ListItemDiscount listItemDiscount = new ListItemDiscount();

            listItemDiscount.Discount = false;
            if (itemList.Count > 0 && IsPalindrome(searchParam))
            {
                listItemDiscount.Discount = true;
                foreach (var position in Enumerable.Range(0, itemList.Count))
                {
                    var item = itemList[position];
                    item.price         = item.price / 2;
                    itemList[position] = item;
                }
            }
            listItemDiscount.ItemList = itemList;
            return(View(listItemDiscount));
        }