Esempio n. 1
0
 public HttpResponseMessage RemoveProductFromBasket(AddToBasketData data)
 {
     var basket = _basketRepository.GetFirstOrDefault(z => z.UserId == data.User.Id && z.DateSuccess == null);
     if (basket == null) return ErrorResult();
     RemoveProductFromBasketByProductId(basket, data.Product.Id, data.Product.Price);
     return SuccessResult();
 }
Esempio n. 2
0
 public HttpResponseMessage ChangeProductCountInBasket(AddToBasketData data)
 {
     var basket = _basketRepository.GetFirstOrDefault(z => z.UserId == data.User.Id && z.DateSuccess == null);
     if (basket == null) return ErrorResult();
     var allLines = ChangeProductCountAndSave(basket, data.Product.Id, data.Product.Count);
     return SuccessResult(GetViewBasketData(basket, allLines));
 }
Esempio n. 3
0
        public HttpResponseMessage AddProductToBasket(AddToBasketData data)
        {
            var userBasket = _basketRepository.GetFirstOrDefault(z => z.DateSuccess == null && z.UserId == data.User.Id);
            var basketId = userBasket == null ? CreateBasket(data.User.Id) : userBasket.Id;
            AddProductToBasket(basketId, data.Product);
            AddProductToBasketLine(data.Product.Id, basketId, data.Product.Count);

            return SuccessResult();
        }