示例#1
0
 public CatalogController(ILibraryAsset assets, ICheckOut checkOuts
                          , LibraryContext context)
 {
     _assets    = assets;
     _checkOuts = checkOuts;
     _context   = context;
 }
示例#2
0
 public CheckOutModel(int id, LibraryAsset asset, ICheckOut CheckOuts) : this(id)
 {
     ImageUrl      = asset.ImageUrl;
     Title         = asset.Title;
     LibraryCardId = string.Empty;//
     IsCheckedOut  = CheckOuts.IsCheckedOut(id);
 }
 public CatalogController(ILibraryAsset assets,
                          ICheckOut checkOut,
                          IHostingEnvironment ho)
 {
     this.assets   = assets;
     this.checkOut = checkOut;
     this.ho       = ho;
 }
示例#4
0
        public void TestInit()
        {
            _pricingRules.Clear();
            _pricingRules.Add(new XForN('A', 3, 1.30M));
            _pricingRules.Add(new XForN('B', 2, 0.45M));
            _pricingRules.Add(new BasePricingRule('C'));
            _pricingRules.Add(new BasePricingRule('D'));
            _pricingRules.Add(new BasePricingRule('E'));

            _checkOut = new CheckOut(_pricingRules);
        }
示例#5
0
        public void TestInitialize()
        {
            IList <Product> Products = new List <Product>();

            Products.Add(new Product("A", 50, new Discount("CODE-3", 3, 130)));
            Products.Add(new Product("B", 30, new Discount("CODE-2", 2, 45)));
            Products.Add(new Product("C", 20, null));
            Products.Add(new Product("D", 15, null));
            _checkout = new CheckOut();
            _checkout.ProductItems = Products;
        }
示例#6
0
        /// <summary>
        /// Resets the check out.
        /// </summary>
        public virtual void ResetCheckOut()
        {
            ICheckOut checkOut = Context.Entity.Resolve <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).HasOtherShippingAddressBeenChecked = false;
            }

            Context.Entity.SetInstance(checkOut);
            Context.Entity.SetInstance(Context.Entity.Resolve <ShoppingCart>());
        }
示例#7
0
        /// <summary>
        /// Handles the Click event of the btnEmptyShoppingCart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnEmptyShoppingCart_Click(object sender, EventArgs e)
        {
            uint       numberOfProducts    = 0;
            ListString shoppingCartContent = new ListString();

            foreach (ShoppingCartLine line in this.Cart.ShoppingCartLines)
            {
                shoppingCartContent.Add(line.Product.Code);
                numberOfProducts += line.Quantity;
            }

            AnalyticsUtil.ShoppingCartEmptied(shoppingCartContent.ToString(), numberOfProducts);

            this.Cart.ShoppingCartLines.Clear();

            ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).ResetCheckOut();
            }

            ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
示例#8
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <exception cref="ValidatorException">Order could not be created.</exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            DomainModel.Carts.ShoppingCart shoppingCart = Sitecore.Ecommerce.Context.Entity.GetInstance <DomainModel.Carts.ShoppingCart>();
            if (string.IsNullOrEmpty(shoppingCart.PaymentSystem.Code))
            {
                return;
            }

            PaymentUrlResolver paymentUrlResolver = new PaymentUrlResolver();
            PaymentArgs        paymentArgs        = new PaymentArgs
            {
                PaymentUrls  = paymentUrlResolver.Resolve(),
                ShoppingCart = shoppingCart
            };

            ITransactionData transactionData = Sitecore.Ecommerce.Context.Entity.Resolve <ITransactionData>();

            PaymentProvider paymentProvider = Sitecore.Ecommerce.Context.Entity.Resolve <PaymentProvider>(shoppingCart.PaymentSystem.Code);

            DomainModel.Payments.PaymentSystem paymentSystem = shoppingCart.PaymentSystem;

            try
            {
                paymentProvider.ProcessCallback(paymentSystem, paymentArgs);
            }
            catch (Exception exception)
            {
                IOrderManager <Order> orderManager = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
                shoppingCart.OrderNumber = orderManager.GenerateOrderNumber();
                transactionData.DeletePersistentValue(shoppingCart.OrderNumber);

                HttpContext.Current.Session["paymentErrorMessage"] = exception.Message;
                this.Response.Redirect(paymentArgs.PaymentUrls.FailurePageUrl);

                return;
            }

            switch (paymentProvider.PaymentStatus)
            {
            case PaymentStatus.Succeeded:
            {
                IOrderManager <Order> orderManager = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
                Order order = orderManager.CreateOrder(shoppingCart);

                if (order != null)
                {
                    // Redirect to order confirmation page
                    string    orderId  = shoppingCart.OrderNumber;
                    ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve <ICheckOut>();
                    if (checkOut is CheckOut)
                    {
                        ((CheckOut)checkOut).ResetCheckOut();
                    }

                    if (MainUtil.IsLoggedIn())
                    {
                        orderId = string.Format("orderid={0}", orderId);
                    }
                    else
                    {
                        string encryptKey = Crypto.EncryptTripleDES(orderId, "5dfkjek5");
                        orderId = string.Format("key={0}", Uri.EscapeDataString(encryptKey));
                    }

                    this.StartOrderCreatedPipeline(order.OrderNumber);

                    if (!string.IsNullOrEmpty(orderId))
                    {
                        UrlString url = new UrlString(paymentArgs.PaymentUrls.SuccessPageUrl);
                        url.Append(new UrlString(orderId));
                        this.Response.Redirect(url.ToString());
                    }
                }
                else
                {
                    IOrderManager <Order> orderProvider = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
                    shoppingCart.OrderNumber = orderProvider.GenerateOrderNumber();
                    transactionData.DeletePersistentValue(shoppingCart.OrderNumber);

                    HttpContext.Current.Session["paymentErrorMessage"] = "Order could not be created.";
                    this.Response.Redirect(paymentArgs.PaymentUrls.FailurePageUrl);
                }

                break;
            }

            case PaymentStatus.Canceled:
            {
                IOrderManager <Order> orderProvider = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
                shoppingCart.OrderNumber = orderProvider.GenerateOrderNumber();
                transactionData.DeletePersistentValue(shoppingCart.OrderNumber);

                HttpContext.Current.Session["paymentErrorMessage"] = "Payment has been aborted by user.";
                this.Response.Redirect(paymentArgs.PaymentUrls.CancelPageUrl);

                break;
            }

            case PaymentStatus.Failure:
            {
                IOrderManager <Order> orderProvider = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
                shoppingCart.OrderNumber = orderProvider.GenerateOrderNumber();
                transactionData.DeletePersistentValue(shoppingCart.OrderNumber);

                this.Response.Redirect(paymentArgs.PaymentUrls.FailurePageUrl);

                break;
            }
            }
        }
示例#9
0
 public CatalogController(ILibraryAsset libraryAsset, ICheckOut checkOut)
 {
     _libraryAsset = libraryAsset;
     _checkOut     = checkOut;
 }
示例#10
0
 public BookController(ILibraryAsset libraryAsset, ICheckOut checkOut)
 {
     _libraryAsset = libraryAsset;
 }
示例#11
0
 public CatalogController(ILibraryAsset assets, ICheckOut checkouts)
 {
     _assets    = assets;
     _checkouts = checkouts;
 }
示例#12
0
 public AssetHoldModel(int id, ICheckOut CheckOut)
 {
     this.HoldPlaced = CheckOut.GetCurrentHoldPlaced(id);
     this.PatronName = CheckOut.GetCurrentHoldPatronName(id);
 }
示例#13
0
 //Constructor
 public MemberController(ILogger <BooksController> logger, IMemberFetcher fetchService, ICheckOut checkOutService)
 {
     _logger          = logger;
     _fetchService    = fetchService;
     _checkOutService = checkOutService;
 }
示例#14
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentException">List of payment methods is empty.</exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            // Checks if the user has appropiate access.
            ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.GetInstance <ICheckOut>();

            if ((checkOut == null) || !(checkOut is CheckOut) || !((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).NameAndAddressDone || !((CheckOut)checkOut).DeliveryDone)
            {
                this.Response.Redirect("/");
            }

            this.lblFormTitle.Text       = Translate.Text(Texts.Payment);
            this.lblFormDescription.Text = Translate.Text(Texts.PleaseSelectAPaymentMethod);
            this.lblpaymentMethods.Text  = string.Concat(Translate.Text(Texts.PaymentMethod), ": ");

            ListItem item = new ListItem {
                Text = "      ", Value = "nonSelected", Selected = true
            };

            this.ddlPaymentMethods.Items.Insert(0, item);

            this.btnConfirm.Text = Translate.Text(Texts.ConfirmPayment);

            IOrderManager <Order> orderProvider = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();

            DomainModel.Carts.ShoppingCart shoppingCart = Sitecore.Ecommerce.Context.Entity.GetInstance <DomainModel.Carts.ShoppingCart>();

            // Sets the ordernumber.
            if (string.IsNullOrEmpty(shoppingCart.OrderNumber))
            {
                string orderno = orderProvider.GenerateOrderNumber();
                if (string.IsNullOrEmpty(orderno))
                {
                    orderno = DateTime.Now.ToString("yyyyMMdd HHmmss");
                }

                shoppingCart.OrderNumber = orderno;

                Sitecore.Ecommerce.Context.Entity.SetInstance(shoppingCart);
            }

            IEntityProvider <PaymentSystem> paymentMethodProvider = Sitecore.Ecommerce.Context.Entity.Resolve <IEntityProvider <PaymentSystem> >();

            Assert.IsNotNull(paymentMethodProvider, "Payment methods provider is null");

            IEnumerable <PaymentSystem> paymentMethods = paymentMethodProvider.GetAll();

            if (paymentMethods.IsNullOrEmpty())
            {
                throw new ArgumentException("List of payment methods is empty.");
            }

            this.repeaterPaymentMethods.DataSource = paymentMethods;
            this.repeaterPaymentMethods.DataBind();

            this.AddOnlinePayMethods();
            this.AddOfflinePayMethods();
            this.SetDefaultPaymentMethod();
        }
示例#15
0
 public CatalogoController(IBibliotecaAtivo ativos, ICheckOut checkOut)
 {
     _ativos    = ativos;
     _checkOuts = checkOut;
 }
示例#16
0
        /// <summary>
        /// Gets the most recent set options from the ShoppingCart and customerInfo instance
        /// and displays the options in the web form.
        /// If there are no items in the ShoppingCart, the user will be redirected to the
        /// home page.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            // Checks if the user has appropiate access.
            ICheckOut checkOut = Context.Entity.GetInstance <ICheckOut>();

            if (checkOut != null && checkOut is CheckOut)
            {
                if (!((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).DeliveryDone)
                {
                    HttpContext.Current.Response.Redirect("/");
                }
            }

            HtmlFormModifier form = new HtmlFormModifier(args);

            form.DisableInputField("UserName");

            /*
             * Item navigationLinkItem = Utils.ItemUtil.GetNavigationLinkItem("Previous");
             * if (navigationLinkItem != null)
             * {
             * form.AddButtonFromNavigationLink(navigationLinkItem, true);
             * }
             */

            // If the user is logged in we hide the Create User boks.
            if (MainUtil.IsLoggedIn())
            {
                form.HideSectionByField("Create Username", "HideCreateUserSection");
            }

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            form.SetInputValue("UserName", customerManager.CurrentUser.Email);

            if (isPostback)
            {
                return;
            }

            ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.CustomerInfo = customerManager.CurrentUser;

            Context.Entity.SetInstance(shoppingCart);

            // Checks the Use other shipping address checkbox.
            // form.SetCheckboxSelected("HideThisSection", true);

            form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
            form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
            form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
            form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);
            form.SetInputValue("Email", customerManager.CurrentUser.Email);

            if (customerManager.CurrentUser.BillingAddress.Country.Code != "US")
            {
                form.HideField("State");
            }
            else
            {
                form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
            }

            if (customerManager.CurrentUser.ShippingAddress.Country.Code != "US")
            {
                form.HideField("ShippingState");
            }
            else
            {
                form.SetSelectedDropListValue("ShippingState", customerManager.CurrentUser.ShippingAddress.State);
            }

            form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Name);

            /*
             * // Only field out shipping address if it was checked before.
             * if (checkOut is CheckOut)
             * {
             * if (!((CheckOut)checkOut).HasOtherShippingAddressBeenChecked)
             * {
             *  return;
             * }
             * }
             */
            form.SetInputValue("ShippingName", customerManager.CurrentUser.ShippingAddress.Name);
            form.SetInputValue("ShippingAddress", customerManager.CurrentUser.ShippingAddress.Address);
            form.SetInputValue("ShippingZip", customerManager.CurrentUser.ShippingAddress.Zip);
            form.SetInputValue("ShippingCity", customerManager.CurrentUser.ShippingAddress.City);

            form.SetSelectedDropListValue("ShippingCountry", customerManager.CurrentUser.ShippingAddress.Country.Title);

            foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
            {
                form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
            }
        }
示例#17
0
        /// <summary>
        /// Adds CustomerInfo, Shippingdetails and Billingdetails into the ShoppingCart instance
        /// Also updates the CustomerInfo session
        /// </summary>
        /// <param name="formid">The formid.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="data">The data.</param>
        /// <exception cref="ValidatorException">Throws <c>ValidatorException</c> in a customer is already exists.</exception>
        public void Execute(ID formid, AdaptedResultList fields, params object[] data)
        {
            AnalyticsUtil.CheckoutNext();

            NameValueCollection orderInfo = new NameValueCollection();

            ActionHelper.FillFormData(orderInfo, fields, this.FillOrderInfo);
            bool isNewUser = false;
            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();
            CustomerInfo customerInfo;

            if (orderInfo["HideCreateUserSection"] == "1" && !string.IsNullOrEmpty(orderInfo["Password"]) && !Sitecore.Context.User.IsAuthenticated)
            {
                try
                {
                    string fullNickName = Sitecore.Context.Domain.GetFullName(orderInfo["Email"]);
                    customerInfo = customerManager.CreateCustomerAccount(fullNickName, orderInfo["Password"], orderInfo["Email"]);
                }
                catch (MembershipCreateUserException ex)
                {
                    Log.Error("Unable to create a customer account.", ex, this);
                    throw new ValidatorException(ex.Message, ex);
                }

                isNewUser = true;
            }
            else
            {
                customerInfo = customerManager.CurrentUser;
            }

            Assert.IsNotNull(customerInfo, "Cannot create user");

            foreach (string key in orderInfo.AllKeys)
            {
                customerInfo[key] = orderInfo[key];
            }

            customerInfo.BillingAddress.Name    = orderInfo["Name"];
            customerInfo.BillingAddress.Address = orderInfo["Address"];
            customerInfo.BillingAddress.Zip     = orderInfo["Zip"];
            customerInfo.BillingAddress.City    = orderInfo["City"];
            customerInfo.BillingAddress.State   = orderInfo["State"];
            customerInfo.Email = orderInfo["Email"];

            // Find country.
            if (!string.IsNullOrEmpty(orderInfo["Country"]))
            {
                IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                customerInfo.BillingAddress.Country = countryProvider.Get(orderInfo["Country"]);
            }

            // If shipping checkbox is checked
            if (orderInfo["HideThisSection"] == "1")
            {
                customerInfo.ShippingAddress.Name    = orderInfo["ShippingName"];
                customerInfo.ShippingAddress.Address = orderInfo["ShippingAddress"];
                customerInfo.ShippingAddress.Zip     = orderInfo["ShippingZip"];
                customerInfo.ShippingAddress.City    = orderInfo["ShippingCity"];
                customerInfo.ShippingAddress.State   = orderInfo["ShippingState"];

                if (!string.IsNullOrEmpty(orderInfo["ShippingCountry"]))
                {
                    IEntityProvider <Country> countryProvider = Context.Entity.Resolve <IEntityProvider <Country> >();
                    customerInfo.ShippingAddress.Country = countryProvider.Get(orderInfo["ShippingCountry"]);
                }
            }
            else
            {
                EntityHelper entityHepler      = Context.Entity.Resolve <EntityHelper>();
                AddressInfo  targetAddressInfo = customerInfo.ShippingAddress;

                entityHepler.CopyPropertiesValues(customerInfo.BillingAddress, ref targetAddressInfo);
            }

            ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.CustomerInfo = customerInfo;

            IEntityProvider <NotificationOption> notificationProvider = Context.Entity.Resolve <IEntityProvider <NotificationOption> >();

            Assert.IsNotNull(notificationProvider, "Notification options provider is null");

            shoppingCart.NotificationOption      = notificationProvider.Get("Email");
            shoppingCart.NotificationOptionValue = orderInfo["Email"];

            if (isNewUser)
            {
                customerManager.UpdateCustomerProfile(customerInfo);
            }

            customerManager.CurrentUser = customerInfo;
            Context.Entity.SetInstance(shoppingCart);

            // Indicates that the form has been filled out and that it should be initialized if the user returnes to this page.
            ICheckOut checkOut = Context.Entity.GetInstance <ICheckOut>();

            if (checkOut is CheckOut)
            {
                ((CheckOut)checkOut).HasOtherShippingAddressBeenChecked = orderInfo["HideThisSection"] == "1";
            }

            Context.Entity.SetInstance(checkOut);

            ItemUtil.RedirectToNavigationLink(NavigationLinkNext, false);
        }
示例#18
0
文件: Shop.cs 项目: D155Y/Shop.Test
 public Shop(IShoppingCart cart, ICheckOut checkout)
 {
     _cart     = cart;
     _checkout = checkout;
 }
示例#19
0
 public PatronService(LibraryContext context, ICheckOutHistory CheckOutHistory, ICheckOut CheckOuts)
 {
     _context         = context;
     _checkOutHistory = CheckOutHistory;
     _CheckOuts       = CheckOuts;
 }
 public CatalogController(ILibraryAsset assets, ICheckOut checkOut)
 {
     _assetServices    = assets;
     _checkoutsService = checkOut;
 }
示例#21
0
 public CatalogController(ILibraryAsset asset, ICheckOut checkout)
 {
     _interface         = asset;
     _checkOutInterface = checkout;
 }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PaymentController"/> class.
 /// </summary>
 /// <param name="checkout">The checkout.</param>
 public PaymentController(ICheckOut checkout)
 {
     this.checkoutManager = checkout;
 }
 public CatalogController(ILibraryAsset asset, ICheckOut checkout)
 {
     _assets   = asset;
     _checkout = checkout;
 }
示例#24
0
 public void Setup()
 {
     this.checkoutHelper = new Mock <ICheckoutHelper>();
     this.checkoutWithMockedDependencies = new CheckOut(this.checkoutHelper.Object);
     this.checkout = new CheckOut(new CheckoutHelper());
 }