public bool UpdateProductItem(ProductItem item)
 {
     if (_productItems.ContainsKey(item.Id))
     {
         _productItems[item.Id] = item.Clone();
     }
     else
     {
         throw new Exception("Item does not exist.");
     }
     return(true);
 }
 private void SaveProductRow()
 {
     if (rowModifiedIndex >= 0)
     {
         ProductItem productItem = dataGridViewProduct.Rows[rowModifiedIndex]?.DataBoundItem as ProductItem;
         if (productItem != null)
         {
             (new DBReader()).ProductUpdateAsync((ProductItem)productItem.Clone());
         }
         rowModifiedIndex = -1;
     }
     ;
 }
        public ProductItem GetProductItem(int inventoryId)
        {
            ProductItem item = null;

            if (_productItems.ContainsKey(inventoryId))
            {
                item = _productItems[inventoryId];
            }
            else
            {
                throw new Exception("Item does not exist.");
            }

            return(item.Clone());
        }
 public int AddProductItem(ProductItem item)
 {
     item.Id = _productId++;
     _productItems.Add(item.Id, item.Clone());
     return(item.Id);
 }