Esempio n. 1
0
        public ActionResult RemoveOrderline(int orderlineId)
        {
            _transactionLibraryInternal.UpdateLineItemByOrderLineId(orderlineId, 0);

            return(Json(new
            {
                orderlineId = orderlineId
            }));
        }
        public ActionResult RemoveOrderline(int orderlineId)
        {
            var    model      = ResolveModel();
            var    parameters = new System.Collections.Generic.Dictionary <string, object>();
            string message;

            if (!model.CanProcessRequest(parameters, out message))
            {
                return(this.PartialView("_Warning", message));
            }

            _transactionLibraryInternal.UpdateLineItemByOrderLineId(orderlineId, 0);
            _transactionLibraryInternal.ExecuteBasketPipeline();
            var vm = model.GetViewModel(Url.Action("UpdateBasket"), Url.Action("RemoveOrderline"));

            var miniBasketModel = ResolveMiniBasketModel();

            return(Json(new
            {
                MiniBasketRefresh = miniBasketModel.Refresh(),
                orderlineId,
                vm.OrderTotal,
                vm.DiscountTotal,
                vm.TaxTotal,
                vm.SubTotal,
                vm.OrderLines
            }));
        }
Esempio n. 3
0
        public virtual CartUpdateBasketViewModel Update(CartUpdateBasket model)
        {
            foreach (var updateOrderline in model.RefreshBasket)
            {
                var newQuantity = updateOrderline.OrderLineQty;
                if (newQuantity <= 0)
                {
                    newQuantity = 0;
                }

                _transactionLibraryInternal.UpdateLineItemByOrderLineId(updateOrderline.OrderLineId, newQuantity);
            }

            _transactionLibraryInternal.ExecuteBasketPipeline();

            var basket = _transactionLibraryInternal.GetBasket(false).PurchaseOrder;

            CartUpdateBasketViewModel updatedBasket = new CartUpdateBasketViewModel();

            foreach (var orderLine in basket.OrderLines)
            {
                var orderLineViewModel = new CartUpdateOrderline();
                orderLineViewModel.OrderlineId       = orderLine.OrderLineId;
                orderLineViewModel.Quantity          = orderLine.Quantity;
                orderLineViewModel.Total             = new Money(orderLine.Total.GetValueOrDefault(), basket.BillingCurrency).ToString();
                orderLineViewModel.Discount          = orderLine.Discount;
                orderLineViewModel.Tax               = new Money(orderLine.VAT, basket.BillingCurrency).ToString();
                orderLineViewModel.Price             = new Money(orderLine.Price, basket.BillingCurrency).ToString();
                orderLineViewModel.PriceWithDiscount = new Money(orderLine.Price - orderLine.Discount, basket.BillingCurrency).ToString();

                updatedBasket.OrderLines.Add(orderLineViewModel);
            }

            string orderTotal    = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            string discountTotal = new Money(basket.DiscountTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            string taxTotal      = new Money(basket.TaxTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            string subTotal      = new Money(basket.SubTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();

            updatedBasket.OrderTotal    = orderTotal;
            updatedBasket.DiscountTotal = discountTotal;
            updatedBasket.TaxTotal      = taxTotal;
            updatedBasket.SubTotal      = subTotal;

            return(updatedBasket);
        }