Example #1
0
        public void RemoveItemFromBasket(int basketId, int productId)
        {
            var basket       = basketRepo.Get(basketId);
            var itemToRemove = basketItemRepo.GetAll().Where(b => (b.Basket.Id == basketId && b.ProductId == productId)).FirstOrDefault();

            basketItemRepo.Delete(itemToRemove);
        }
Example #2
0
        public Entity Handle(BasketAddModel model)
        {
            var account = GetAccount();

            var basket = BasketRepository.Get(account);

            basket.AddItem(ItemRepository.Get(model.Id));
            BasketRepository.Save(account, basket);

            return(BuildEntity(basket, account));
        }
        public void Do(BasketId basketId)
        {
            BasketDTO basket = _basketRepository.Get(basketId.ConsumerId, basketId.Id);

            if (basket != null)
            {
                _basketRepository.Delete(basketId.ConsumerId, basketId.Id);
            }
        }
Example #4
0
        public Basket GetBasket(string userId)
        {
            var basket = _repo.Get(q => q.UserId == userId, null, "Products.Product").FirstOrDefault();

            if (basket == null)
            {
                return(CreateBasket(userId));
            }
            return(basket);
        }
        public string Do(string consumerId)
        {
            BasketDTO basket = _basketRepository.Get(consumerId);

            if (basket != null)
            {
                return(basket.Id);
            }

            return(_basketRepository.Create(consumerId));
        }
Example #6
0
        public async Task basket_can_be_retrieved_by_user_id()
        {
            //arrange
            var user = new User {
                Basket = new Basket()
            };

            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            //act
            var result = await _testClass.Get(user.Id);

            //assert
            Assert.Equal(0, result.Items.Count());
        }
Example #7
0
 private void GetConsumerBasketReturns(BasketDTO basket)
 {
     A.CallTo(() => _basketRepository.Get(_consumerId, _basketId))
     .Returns(basket);
 }
        public async Task <IActionResult> Get(long userId)
        {
            var basket = await _repository.Get(userId);

            return(new ObjectResult(basket));
        }
Example #9
0
 private void ConsumerDoesntHaveBasket()
 {
     A.CallTo(() => _basketRepository.Get(_consumerId))
     .Returns(null);
 }
Example #10
0
 public BasketDTO Get(BasketId basketId)
 {
     return(_basketRepository.Get(basketId.ConsumerId,
                                  basketId.Id));
 }