Ejemplo n.º 1
0
        public bool SetQuantity(int eventId, int quantity)
        {
            bool doesContainEvent = BasketPositions.Any(item => item.Event.Id == eventId);

            if (!doesContainEvent)
            {
                return(false);
            }

            CartPosition bp = BasketPositions.First(item => item.Event.Id == eventId);

            bp.Quantity = quantity;
            return(true);
        }
Ejemplo n.º 2
0
        public void AddFewToBasket(Event Event, int quantity)
        {
            bool doesContainEvent = BasketPositions.Any(item => item.Event.Id == Event.Id);

            if (!doesContainEvent)
            {
                BasketPositions.Add(CartPosition.Create(Event, quantity));
            }
            else
            {
                CartPosition bp = BasketPositions.First(item => item.Event.Id == Event.Id);
                bp.Quantity += quantity;
            }
        }
Ejemplo n.º 3
0
        public bool RemoveFromBasket(int eventId, int quantity)
        {
            bool doesContainEvent = BasketPositions.Any(item => item.Event.Id == eventId);

            if (doesContainEvent)
            {
                CartPosition bp = BasketPositions.First(item => item.Event.Id == eventId);
                if (bp.Quantity > quantity)
                {
                    bp.Quantity -= quantity;
                }
                else
                {
                    BasketPositions.Remove(bp);
                }

                return(true);
            }

            return(false);
        }