Exemplo n.º 1
0
 private void addItemButton_Click(object sender, EventArgs e)
 {
     aProduct=new Product();
     aProduct.ProductId = productIdTextBox.Text;
     aProduct.Quantity = Convert.ToInt32(quantityTextBox.Text);
        MessageBox.Show( aShop.AddItem(aProduct.ProductId,aProduct.Quantity));
 }
Exemplo n.º 2
0
        private bool HasThisProductIdExist(string prouctId)
        {
            foreach (Product product in productList)
            {
                if (product.ProductId== prouctId)
                {
                    aProduct = product;
                    return true;
                }

            }
               return false;
        }
Exemplo n.º 3
0
        public string AddItem(string productId, int quantity)
        {
            string msg = "";
               if (HasThisProductIdExist(productId))
               {
               aProduct.Quantity += quantity;
               msg = "Already exist! Quantity added";
               }

               else
               {
               aProduct = new Product();
               aProduct.ProductId = productId;
               aProduct.Quantity = quantity;
               productList.Add(aProduct);
               msg="Item added";
               }
               return msg;
        }