Ejemplo n.º 1
0
        public void TestBasket()
        {
            var customer = new CustomerAction(8);
            var store    = new StoreAction();

            customer.ClearBasket();

            customer.AddBasket(GenerateBasketElement());
            customer.AddBasket(GenerateBasketElement());
            Assert.IsTrue(customer.GetBasket().Count() == 2);
            customer.DelBasket(customer.GetBasket().First().id);
            Assert.IsTrue(customer.GetBasket().Count() == 1);
        }
Ejemplo n.º 2
0
        public JsonResult DeleteBasket(long basketId)
        {
            var customer = new CustomerAction(Session.GetUser().id);

            try
            {
                customer.DelBasket(basketId);
                Session.UpdateBasket();
                var basketSum   = customer.GetBasket()?.Sum(s => s.summTotal) ?? 0.00M;
                var basketCount = customer.GetBasket()?.Count() ?? 0;
                return(Json(new { result = 0, basketSum = basketSum, basketCount = basketCount }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = -1, message = "Ошибка удаления из корзины. Перезагрузите страницу" }, JsonRequestBehavior.AllowGet));
            }
        }