Ejemplo n.º 1
0
        public ActionResult Signup()
        {
            var shape = _services.New.Checkout_Signup(Signup: new SignupViewModel
            {
                ShowReceiveNewsletter = _webshopSettings.GetShowSubscribeToMailingList(),
                ShowAcceptTerms       = _webshopSettings.GetShowTermsAndConditions(),
                TermsAndConditionsUrl = _webshopSettings.GetTermsAndConditionsUrl(),
                PrivacyUrl            = _webshopSettings.GetPrivacyUrl(),
                ContinueShoppingUrl   = _webshopSettings.GetContinueShoppingUrl()
            });

            return(new ShapeResult(this, shape));
        }
Ejemplo n.º 2
0
 protected override DriverResult Display(ShoppingCartWidgetPart part, string displayType, dynamic shapeHelper)
 {
     return(ContentShape("Parts_ShoppingCartWidget", () => shapeHelper.Parts_ShoppingCartWidget(
                             ItemCount: _shoppingCart.ItemCount(),
                             TotalAmount: _shoppingCart.Total(),
                             ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl()
                             )));
 }
Ejemplo n.º 3
0
        public ActionResult Cancel(string token)
        {
            // Todo: obtain payment and error details

            // Display reason for failure and suggestions for how to overcome
            //string paymentId = "";
            //string command = "Failed";
            //string orderReference = token;
            //return RedirectToAction("PaymentResponse", "Order", new { area = "Cascade.WebShop", paymentId = paymentId, result = command, orderReference });

            string baseUrl    = "http://" + Request.Url.Authority;
            string catalogUrl = baseUrl + _webshopSettings.GetContinueShoppingUrl();

            return(Redirect(catalogUrl));
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            // Create a new shape using the "New" property of IOrchardServices.
            var shape = _services.New.ShoppingCart(
                Products: _shoppingCart.GetProducts().Select(p => _services.New.ShoppingCartItem(
                                                                 ProductPart: p.ProductPart,
                                                                 Quantity: p.Quantity,
                                                                 Type: p.ProductPart.TypeDefinition.Name,
                                                                 Title: _services.ContentManager.GetItemMetadata(p.ProductPart).DisplayText)
                                                             ).ToList(),
                Total: _shoppingCart.Total(),
                Subtotal: _shoppingCart.Subtotal(),
                GST: _shoppingCart.GST(),
                ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl()
                );


            // Return a ShapeResult
            return(new ShapeResult(this, shape));
        }
Ejemplo n.º 5
0
        public ActionResult PaymentResponse()
        {
            var args = new PaymentResponse(HttpContext);

            foreach (var handler in _paymentServiceProviders)
            {
                handler.ProcessResponse(args);

                if (args.WillHandleResponse)
                {
                    break;
                }
            }

            if (!args.WillHandleResponse)
            {
                throw new OrchardException(_t("Such things mean trouble"));
            }

            var order = _orderService.GetOrderByNumber(args.OrderReference);

            _orderService.UpdateOrderStatus(order, args);

            var user = _authenticationService.GetAuthenticatedUser();

            if (user == null)
            {
                throw new OrchardSecurityException(_t("Login required"));
            }

            var customer = user.ContentItem.As <CustomerPart>();

            if (customer == null)
            {
                throw new InvalidOperationException("The current user is not a customer");
            }

            if (order.Status == OrderStatus.Paid)
            {
                // send an email confirmation to the customer
                string subject = string.Format("Your Order Number {0} has been received", order.Id);
                string body    = string.Format("Dear {0}<br/><br/>Thank you for your order.<br/><br/>You will receive a Tax Invoice when your order is shipped.", customer.FirstName);
                _messageManager.Process(new Dictionary <string, object>
                {
                    { "Recipients", user.Email },
                    { "Subject", subject },
                    { "Body", body }
                });

                //_messageManager.Send(user.ContentItem.Record, "ORDER_RECEIVED", "email", new Dictionary<string, string>
                //{
                //    { "Subject", subject },
                //    { "Body", body}
                //});

                // send a copy of the order to the administator
                _messageManager.Process(new Dictionary <string, object>
                {
                    { "Recipients", _webshopSettings.GetAdministratorEmail() },
                    { "Subject", string.Format("Order Number {0} received from {1} {2}", order.Id, customer.FirstName, customer.LastName) },
                    { "Body", body }
                });


                //string adminEmail = _webshopSettings.GetAdministratorEmail();
                //if (!string.IsNullOrWhiteSpace(adminEmail))
                //    _messageManager.Send(new List<string> { adminEmail}, "ORDER_RECEIVED", "email", new Dictionary<string, string>
                //    {
                //        { "Subject", string.Format("Order Number {0} received from {1} {2}", order.Id, customer.FirstName, customer.LastName) },
                //        { "Body", body}
                //    });

                // decrement stock levels
                _shoppingCart.RemoveFromStock();

                // finally, clear the order
                _shoppingCart.Clear();
            }

            return(new ShapeResult(this, _shapeFactory.Order_PaymentResponse(Order: order, PaymentResponse: args, ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl())));
        }