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); }
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; } }
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); }