예제 #1
0
        public IActionResult List()
        {
            var model = new ListViewModel();
            CheckAvailability checker = new CheckAvailability(_itemData);

            _itemData.Save();
            var allItems = _itemData.GetAll();

            model.List = allItems;
            var unAvailableItems = allItems.Where(l => l.IsAvailable == false);
            var availableItems   = allItems.Where(l => l.IsAvailable == true);

            model.AvailableItems   = availableItems;
            model.UnAvailableItems = unAvailableItems;
            return(View(model));
        }
예제 #2
0
        public ItemDetails(IBtwTypeData btwTypeData, ICatagoryData catagoryData, IItemData itemData)
        {
            /*
             * IItemData itemData = DependencyResolver.Current.GetService<IItemData>();
             */

            IEnumerable <Item> items = itemData.GetAll();

            List <ItemDetail> newItems = new List <ItemDetail>();

            foreach (Item item in items)
            {
                newItems.Add(new ItemDetail(btwTypeData, catagoryData, itemData, item.Id));
            }
            Items = newItems;
        }
예제 #3
0
 public CheckAvailability(IItemData itemData)
 {
     _itemData = itemData.GetAll();
     foreach (var i in _itemData)
     {
         string toCheck = _siteReader.Read(i.Link);
         if (toCheck == null)
         {
             throw new Exception("Link is Empty");
         }
         else if (toCheck.IndexOf("title=\"Produkt dostępny") != -1)
         {
             i.IsAvailable = true;
         }
         else if (toCheck.IndexOf("batterylow") != -1)
         {
             i.IsAvailable = false;
         }
     }
     itemData.Save();
 }
예제 #4
0
        // GET: /<controller>/
        public IActionResult Display()
        {
            var model = _itemData.GetAll();

            return(View(model));
        }
예제 #5
0
 public ItemsInCatagory(ICatagoryData catagoryData, IItemData itemData, int catagoryId)
 {
     CatagoryName = catagoryData.Get(catagoryId).Name;
     Items        = itemData.GetAll().Where(i => i.CatagoryId == catagoryId);
 }