public Inventory Item(int index) { if (InventoryItems != null && InventoryItems.Any()) { return(InventoryItems.ElementAt(index)); } return(null); }
public void CalculateTotalValuesOfInventory() { if (InventoryItems.Any()) { TotalCostValue = InventoryItems.Sum(x => x.CostPrice); TotalRetailValue = InventoryItems.Sum(x => x.RetailPrice); } TotalCostValue = 0; TotalRetailValue = 0; }
public void AddItem(IInventoryItem item) { if (!InventoryItems.Any(i => i.Name.Equals(item.Name) && i.Category.Equals(item.Category))) { InventoryItems.Add(item); } else { throw new Exception(string.Format("Item {0} in {1} category is already in the inventory", item.Name, item.Category)); } }
private void BtnAddDetail_Click(object sender, EventArgs e) { if (cmbDetailItems.SelectedIndex == -1) { MessageBox.Show("Please select a detail item"); return; } InventoryItem item = _context.InventoryItems.FirstOrDefault(i => i.ID == (int)cmbDetailItems.SelectedValue); if (!InventoryItems.Any(i => i.ID == item.ID)) { InventoryItems.Add(item); } }
/// <summary> /// We will look at the InventoryItems if the current text in the textbox is in the ListView /// we just need to add to the count, if not we need to add to the InventoryItems /// </summary> private void AddItemToList() { if (InventoryItems.Any(p => p.Name == InputName) && InventoryItems.Count > 0) { InventoryItems.First(x => x.Name == InputName).ItemCount++; } else { if (string.IsNullOrEmpty(InputName)) { MessageBox.Show("Please enter an item in the text box"); return; } InventoryItems.Add(new InventoryItem() { Name = InputName, ItemCount = 1 }); } Item = new InventoryItem(); }
public bool HasItem(string name, string category) { return(InventoryItems.Any(i => i.Name.Equals(name) && i.Category.Equals(category))); }