コード例 #1
0
        public void UpdateItem(string id, string itemReference, int newQuantity)
        {
            BasketDTOInMemory  basket = _baskets.Find(x => x.Id == id);
            BasketItemInMemory item   = basket.Items.Find(x => x.ProductReference == itemReference) as BasketItemInMemory;

            item.Quantity = newQuantity;
        }
コード例 #2
0
        public void DeleteItem(string id, string itemReference)
        {
            BasketDTOInMemory basket = _baskets.Find(x => x.Id == id);
            BasketItemDTO     item   = basket.Items.Find(x => x.ProductReference == itemReference);

            basket.Items.Remove(item);
        }
コード例 #3
0
        public void Delete(string consumerId,
                           string basketId)
        {
            BasketDTOInMemory basket = _baskets.Find(x => x.ConsumerId == consumerId &&
                                                     x.Id == basketId);

            _baskets.Remove(basket);
        }
コード例 #4
0
        public string Create(string consumerId)
        {
            BasketDTOInMemory basket = new BasketDTOInMemory(
                Guid.NewGuid().ToString(),
                consumerId);

            _baskets.Add(basket);

            return(basket.Id);
        }
コード例 #5
0
        public void AddItem(string consumerId,
                            string basketId,
                            string productReference,
                            int quantity)
        {
            BasketDTOInMemory basket = _baskets.Find(x => x.ConsumerId == consumerId &&
                                                     x.Id == basketId);
            BasketItemInMemory item = new BasketItemInMemory(productReference, quantity);

            basket.Items.Add(item);
        }