Пример #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);
        }
Пример #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;
            }
        }
Пример #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);
        }