public IHttpActionResult GetBasket()
        {
            if (!TransactionLibrary.HasBasket())
            {
                return(Json(new BasketDTO()));
            }

            return(Json(this.GetBasketModel()));
        }
    private bool SetupIsNeeded()
    {
        if (IsPostBack || ViewMode.IsDesign() || ViewMode.IsEdit())
        {
            return(false);
        }
        if (!TransactionLibrary.HasBasket())
        {
            return(false);
        }

        return(true);
    }
Example #3
0
    private bool SetupIsNeeded()
    {
        if (IsPostBack || ViewMode.IsDesign() || ViewMode.IsEdit())
        {
            return(false);
        }
        if (!TransactionLibrary.HasBasket())
        {
            cartIsEmpty.Visible = true;
            Address.Visible     = false;

            return(false);
        }

        return(true);
    }
Example #4
0
// GET: MiniBasket
        public ActionResult Index()
        {
            var miniBasket = new MiniBasketViewModel();

            miniBasket.IsEmpty = true;

            if (TransactionLibrary.HasBasket())
            {
                PurchaseOrder basket        = TransactionLibrary.GetBasket(false).PurchaseOrder;
                var           numberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                if (numberOfItems != 0)
                {
                    miniBasket.Total         = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency);
                    miniBasket.NumberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                    miniBasket.IsEmpty       = false;
                }
            }
            return(View("/Views/PartialView/MiniBasket.cshtml", miniBasket));
        }
        public ActionResult Index()
        {
            if (!TransactionLibrary.HasBasket())
            {
                return(View(new MiniBasketModel()
                {
                    HasBasket = false
                }));
            }
            ;

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

            return(View(new MiniBasketModel()
            {
                HasBasket = true,
                NumberOfItemsInBasket = basket.OrderLines.Sum(x => x.Quantity),
                OrderTotal = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency).ToString()
            }));
        }
Example #6
0
// GET: MiniBasket
        public ActionResult Index()
        {
            var miniBasket = new MiniBasketViewModel();

            miniBasket.IsEmpty = true;

            if (TransactionLibrary.HasBasket())
            {
                PurchaseOrder basket = TransactionLibrary.GetBasket(false).PurchaseOrder;

                var numberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                if (numberOfItems != 0)
                {
                    foreach (var orderLine in basket.OrderLines)
                    {
                        var miniOrderLineViewModel = new MiniOrderlineViewModel
                        {
                            Quantity          = orderLine.Quantity,
                            ProductName       = orderLine.ProductName,
                            Sku               = orderLine.Sku,
                            VariantSku        = orderLine.VariantSku,
                            Total             = new Money(orderLine.Total.GetValueOrDefault(), basket.BillingCurrency).ToString(),
                            Discount          = orderLine.Discount,
                            Tax               = new Money(orderLine.VAT, basket.BillingCurrency).ToString(),
                            Price             = new Money(orderLine.Price, basket.BillingCurrency).ToString(),
                            ProductUrl        = CatalogLibrary.GetNiceUrlForProduct(CatalogLibrary.GetProduct(orderLine.Sku)),
                            PriceWithDiscount = new Money(orderLine.Price - orderLine.UnitDiscount.GetValueOrDefault(), basket.BillingCurrency).ToString(),
                            OrderLineId       = orderLine.OrderLineId
                        };


                        miniBasket.MiniOrderlineViewModelCollection.Add(miniOrderLineViewModel);
                    }

                    miniBasket.Total         = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency);
                    miniBasket.NumberOfItems = basket.OrderLines.Sum(x => x.Quantity);
                    miniBasket.IsEmpty       = false;
                }
            }
            return(View("/Views/PartialView/MiniBasket.cshtml", miniBasket));
        }
Example #7
0
        public ActionResult Index()
        {
            var    miniBasketModel = ResolveModel();
            string message;

            var parameters = new System.Collections.Generic.Dictionary <string, object>();

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

            var miniBasketRenderingViewModel = miniBasketModel.CreateViewModel(Url.Action("Refresh"));
            var detailTemplateName           = this.detailTemplateNamePrefix + this.TemplateName;

            if (!TransactionLibrary.HasBasket())
            {
                return(View(detailTemplateName, miniBasketRenderingViewModel));
            }

            return(View(detailTemplateName, miniBasketRenderingViewModel));
        }
Example #8
0
        public IHttpActionResult PutProductReview([FromBody] ProductReviewDTO model)
        {
            var product = Product.FirstOrDefault(x => x.Sku == model.Sku && x.VariantSku == null);
            var request = System.Web.HttpContext.Current.Request;
            var basket  = TransactionLibrary.HasBasket() ? TransactionLibrary.GetBasket(false) : null;

            if (basket != null)
            {
                if (basket.PurchaseOrder.Customer == null)
                {
                    basket.PurchaseOrder.Customer = new Customer()
                    {
                        FirstName = model.Name, LastName = string.Empty, EmailAddress = model.Email
                    };
                    basket.Save();
                }
            }

            var review = new ProductReview()
            {
                ProductCatalogGroup = SiteContext.Current.CatalogContext.CurrentCatalogGroup,
                ProductReviewStatus = ProductReviewStatus.SingleOrDefault(s => s.Name == "New"),
                CreatedOn           = DateTime.Now,
                CreatedBy           = model.Name,
                Product             = product,
                Customer            = basket?.PurchaseOrder?.Customer,
                Rating         = model.Rating,
                ReviewHeadline = model.Title,
                ReviewText     = model.Comments,
                Ip             = request.UserHostName,
            };

            product.AddProductReview(review);

            PipelineFactory.Create <ProductReview>("ProductReview").Execute(review);

            return(Ok());
        }
Example #9
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do not process
        }
        else
        {
            string textColor   = ValidationHelper.GetString(GetValue("TextColor"), "black").ToLower();
            bool   valuePrice  = ValidationHelper.GetBoolean(GetValue("ShowPrice"), false);
            bool   valueAmount = ValidationHelper.GetBoolean(GetValue("ShowProductAmount"), false);
            string iconColor   = ValidationHelper.GetString(GetValue("IconColor"), "black").ToLower();

            if (!TransactionLibrary.HasBasket())
            {
                lblMinicartAmount.Text = "Your basket is empty";
                hlMinicart.Attributes.Add("class", "" + textColor);
                return;
            }

            var purchaseOrder         = TransactionLibrary.GetBasket(false).PurchaseOrder;
            var numberOfItemsInBasket = purchaseOrder.OrderLines.Sum(x => x.Quantity);
            var basketTotal           = purchaseOrder.OrderTotal.HasValue ? new Money(purchaseOrder.OrderTotal.Value, purchaseOrder.BillingCurrency) : new Money(0, purchaseOrder.BillingCurrency);

            hlMinicart.Attributes.Add("href", "~/basket");
            hlMinicart.Attributes.Add("class", "" + textColor);
            imgMinicart.Attributes.Add("class", "icon-shopping-cart icon-" + iconColor);
            if (valuePrice)
            {
                lblMinicartPrice.Text = basketTotal.ToString();
            }
            if (valueAmount)
            {
                lblMinicartAmount.Text = $"{numberOfItemsInBasket} item(s)";
            }
        }
    }
Example #10
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do not process
        }
        else
        {
            bool orderlineItemNo   = ValidationHelper.GetBoolean(GetValue("OrderlineItemNo"), true);
            bool orderlinePrice    = ValidationHelper.GetBoolean(GetValue("OrderlinePrice"), true);
            bool orderlineVat      = ValidationHelper.GetBoolean(GetValue("OrderlineVAT"), true);
            bool orderlineQuantity = ValidationHelper.GetBoolean(GetValue("OrderlineQuantity"), true);
            bool orderSubTotal     = ValidationHelper.GetBoolean(GetValue("OrderSubTotal"), true);
            bool orderVat          = ValidationHelper.GetBoolean(GetValue("OrderVat"), true);
            bool orderDiscount     = ValidationHelper.GetBoolean(GetValue("OrderDiscount"), true);
            bool orderShipping     = ValidationHelper.GetBoolean(GetValue("OrderShipping"), true);
            bool orderPayment      = ValidationHelper.GetBoolean(GetValue("OrderPayment"), true);


            if (!orderlinePrice)
            {
                price.InnerText = "";
            }
            if (!orderlineVat)
            {
                vat.InnerText = "";
            }
            if (!orderlineQuantity)
            {
                quantity.InnerText = "";
            }
            if (!orderlineItemNo)
            {
                itemno.InnerText = "";
            }

            PurchaseOrder basket = null;

            if (TransactionLibrary.HasBasket())
            {
                basket = TransactionLibrary.GetBasket(false).PurchaseOrder;
            }

            if (basket == null || basket.OrderLines.Count == 0)
            {
                test.Visible      = true;
                cartPanel.Visible = false;

                return;
            }

            Currency currency = basket.BillingCurrency;

            var subTotal   = new Money(0, currency);
            var tax        = new Money(0, currency);
            var discount   = new Money(0, currency);
            var shipping   = new Money(0, currency);
            var payment    = new Money(0, currency);
            var orderTotal = new Money(0, currency);

            if (basket.SubTotal.HasValue)
            {
                subTotal = new Money(basket.SubTotal.Value, currency);
            }
            if (basket.VAT.HasValue)
            {
                tax = new Money(basket.VAT.Value, currency);
            }
            if (basket.DiscountTotal.HasValue)
            {
                discount = new Money(basket.DiscountTotal.Value * -1, currency);
            }
            if (basket.ShippingTotal.HasValue)
            {
                shipping = new Money(basket.ShippingTotal.Value, currency);
            }
            if (basket.PaymentTotal.HasValue)
            {
                payment = new Money(basket.PaymentTotal.Value, currency);
            }
            if (basket.OrderTotal.HasValue)
            {
                orderTotal = new Money(basket.OrderTotal.Value, currency);
            }

            litSubtotal.Text = subTotal.ToString();
            litTax.Text      = tax.ToString();
            litDiscount.Text = discount.ToString();
            litShipping.Text = shipping.ToString();
            litPayment.Text  = payment.ToString();
            litTotal.Text    = orderTotal.ToString();

            subOrder.Visible      = orderSubTotal;
            vatOrder.Visible      = orderVat;
            discountOrder.Visible = orderDiscount;
            shippingOrder.Visible = orderShipping;
            paymentOrder.Visible  = orderPayment;


            rptCart.DataSource = basket.OrderLines;
            rptCart.DataBind();
        }
    }