private PurchaseOrderViewModel MapOrder()
		{
		    var basket = TransactionLibrary.GetBasket(false).PurchaseOrder;
			var basketModel = new PurchaseOrderViewModel
			{
			    SubTotal = new Money(basket.SubTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(),
			    ShippingTotal = new Money(basket.ShippingTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(),
			    PaymentTotal = new Money(basket.PaymentTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(),
			    DiscountTotal = new Money(basket.DiscountTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(),
			    TaxTotal = new Money(basket.TaxTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(),
                OrderTotal = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency).ToString()
			};

		    foreach (var orderLine in basket.OrderLines)
		    {
                basketModel.OrderLines.Add(new OrderlineViewModel()
		        {
		            OrderLineId = orderLine.OrderLineId,
                    ProductName = orderLine.ProductName,
                    Sku = orderLine.Sku,
                    VariantSku = orderLine.VariantSku,
                    Quantity = orderLine.Quantity,
                    Total = new Money(orderLine.Total.GetValueOrDefault(), basket.BillingCurrency).ToString()
		        });
		    }

		    
			return basketModel;
		}
		public ActionResult Index(PurchaseOrderViewModel model)
		{
		    foreach (var orderLine in model.OrderLines)
		    {
		        var newQuantity = orderLine.Quantity;
		        if (model.RemoveOrderlineId == orderLine.OrderLineId)
		            newQuantity = 0;
		        TransactionLibrary.UpdateLineItem(orderLine.OrderLineId, newQuantity);
		    }
            TransactionLibrary.ExecuteBasketPipeline(); //important every time we update the basket
            //return Index();
            return RedirectToAction("Index");
		}
        public ActionResult Index(PurchaseOrderViewModel model)
        {
            foreach (var orderLine in model.OrderLines)
            {

                var newQuantity = orderLine.Quantity;
                if (model.RemoveOrderlineId == orderLine.OrderLineId)
                {
                    newQuantity = 0;

                    UCommerce.Api.TransactionLibrary.UpdateLineItem(orderLine.OrderLineId, newQuantity);
                }

            }

            UCommerce.Api.TransactionLibrary.ExecuteBasketPipeline(); // everytime we modify the basket, execute pipeline
            return Index();
        }
	    private PurchaseOrderViewModel GetBasket()
	    {
	        var order = TransactionLibrary.GetBasket(false).PurchaseOrder;
	        var basket = new PurchaseOrderViewModel();
            basket.OrderTotal = new Money(order.OrderTotal.GetValueOrDefault(), order.BillingCurrency).ToString();
	        foreach (var orderLine in order.OrderLines)
	        {
	            basket.OrderLines.Add(new OrderlineViewModel()
	            {
	                OrderLineId = orderLine.OrderLineId,
                    ProductName = orderLine.ProductName,
                    Quantity = orderLine.Quantity,
                    Sku = orderLine.Sku,
                    VariantSku = orderLine.VariantSku,
                    Total = new Money(orderLine.Total.GetValueOrDefault(), order.BillingCurrency).ToString()
	            });
	        }
            basket.OrderTotal = new Money(order.OrderTotal.GetValueOrDefault(), order.BillingCurrency).ToString();

	        return basket;
	    }
        private PurchaseOrderViewModel MapBasket()
        {

            UCommerce.EntitiesV2.PurchaseOrder uCommerceOrder = TransactionLibrary.GetBasket(false).PurchaseOrder;
            var basketModel = new PurchaseOrderViewModel();
            basketModel.OrderTotal = new UCommerce.Money(uCommerceOrder.OrderTotal.GetValueOrDefault(), uCommerceOrder.BillingCurrency).ToString();

            foreach (var uCOmmerceOrderLine in uCommerceOrder.OrderLines)
            {
                basketModel.OrderLines.Add(new OrderlineViewModel()
                {
                    OrderLineId = uCOmmerceOrderLine.OrderLineId,
                    ProductName = uCOmmerceOrderLine.ProductName,
                    Quantity = uCOmmerceOrderLine.Quantity,
                    Sku = uCOmmerceOrderLine.Sku,
                    VariantSku = uCOmmerceOrderLine.VariantSku,
                    Total = new UCommerce.Money(uCOmmerceOrderLine.Total.GetValueOrDefault(),
                        uCommerceOrder.BillingCurrency).ToString()
                });

            }

            return basketModel;
        }
		public ActionResult Index()
		{
			var basketModel = new PurchaseOrderViewModel();
		    basketModel = GetBasket();
			return View("/Views/Basket.cshtml", basketModel);
		}