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)); }
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; }
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(); }
// GET: /<controller>/ public IActionResult Display() { var model = _itemData.GetAll(); return(View(model)); }
public ItemsInCatagory(ICatagoryData catagoryData, IItemData itemData, int catagoryId) { CatagoryName = catagoryData.Get(catagoryId).Name; Items = itemData.GetAll().Where(i => i.CatagoryId == catagoryId); }