Esempio n. 1
0
        private void RemoveProductFromBasketByProductId(Basket basket, Guid productId, decimal productPrice)
        {
            var line = _basketLineRepository.GetFirstOrDefault(z => z.BasketId == basket.Id && z.ProductId == productId);

            _basketLineRepository.DeleteItem(z => z.Id == line.Id);
            basket.Total = basket.Total - line.Count * productPrice;
            _basketRepository.UpdateBasket(basket);

            var allLines = _basketLineRepository.FindAll(z => z.BasketId == basket.Id);

            if (allLines.Count == 0)
            {
                _basketRepository.DeleteItem(z => z.Id == basket.Id);
            }
        }
 public void Do(BasketId basketId,
                string itemReference,
                int quantity)
 {
     if (quantity <= 0)
     {
         _basketRepository.DeleteItem(basketId.Id,
                                      itemReference);
     }
     else
     {
         _basketRepository.UpdateItem(basketId.Id,
                                      itemReference,
                                      quantity);
     }
 }
 private void ItemIsRemoved()
 {
     A.CallTo(() => _basketRepository.DeleteItem(_basketId.Id, _itemReference))
     .MustHaveHappened();
 }