Beispiel #1
0
        public bool IncreaseCakeAmount(int cakeID)
        {
            CakeInOrder found = null;

            foreach (var x in listCakes)
            {
                if (x.cake.ID == cakeID)
                {
                    found = x;
                }
            }
            if (found != null && !_cakeServices.checkOutOfCake(cakeID))
            {
                found.Amount++;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public bool DecreaseCakeAmount(int cakeID)
        {
            CakeInOrder found = null;

            foreach (var x in listCakes)
            {
                if (x.cake.ID == cakeID)
                {
                    found = x;
                }
            }
            if (found != null && found.Amount >= 1)
            {
                found.Amount--;
            }
            if (found.Amount == 0)
            {
                DeleteFromOrder(cakeID);
            }
            return(true);
        }
Beispiel #3
0
        public CakeInOrder AddCake(CakeModel cake, int numberOfCake)
        {
            CakeInOrder cakeInOrder = new CakeInOrder
            {
                CakeID    = cake.ID,
                SellPrice = cake.SellingPrice,
                Amount    = numberOfCake,
                cake      = _cakeServices.loadSingleCake(cake.ID)
            };

            int check = CheckExistedCake(cakeInOrder.CakeID);

            if (check == -1)
            {
                listCakes.Add(cakeInOrder);
            }
            else
            {
                listCakes[check].Amount++;
            }


            return(cakeInOrder);
        }