예제 #1
0
        public void RemoveLivestock(Livestock product_out)
        {
            //first lets find the product we need to remove from the order
            CartLivestock find = livestockList.FirstOrDefault(p => p.ProductCode == product_out.ProductCode);

            if (find != null)
            {
                if (find.Stock == 1)
                {
                    livestockList.Remove(find);
                    if (livestockList.Count() == 0)
                    {
                        ContainsLivestock = false;
                    }
                }
                else
                {
                    find.Stock -= 1;
                }
                OrderPrice -= product_out.Price;
            }
        }
예제 #2
0
        //Methods
        public void AddLivestock(Livestock product_in)
        {
            CartLivestock find = livestockList.FirstOrDefault(l => l.ProductCode == product_in.ProductCode);

            if (find == null)
            {
                CartLivestock newOrderProd = new CartLivestock(product_in.CareLevel, product_in.Temperment, product_in.WaterType, product_in.Colours, product_in.WaterConditions, product_in.MaxSize, product_in.Name, product_in.Description, product_in.Price)
                {
                    ProductCode = product_in.ProductCode
                };
                newOrderProd.Stock = 1;
                ContainsLivestock  = true;
                livestockList.Add(newOrderProd);
            }
            else
            {
                if (product_in.Stock > find.Stock)
                {
                    find.Stock++;
                }
            }

            OrderPrice += product_in.Price;
        }