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); }
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); } }
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)); }
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()); }
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)); }
private void ConsumerDoesntHaveBasket() { A.CallTo(() => _basketRepository.Get(_consumerId)) .Returns(null); }
public BasketDTO Get(BasketId basketId) { return(_basketRepository.Get(basketId.ConsumerId, basketId.Id)); }