public override ActionResult Index(RenderModel model)
        {
            var shipping = new ShippingViewModel();

            shipping.AvailableShippingMethods = new List <SelectListItem>();

            var shippingInformation = TransactionLibrary.GetShippingInformation();

            var availableShippingMethods = TransactionLibrary.GetShippingMethods(shippingInformation.Country);

            var basket = TransactionLibrary.GetBasket().PurchaseOrder;

            shipping.SelectedShippingMethodId = basket.Shipments.FirstOrDefault() != null
                ? basket.Shipments.FirstOrDefault().ShippingMethod.ShippingMethodId : -1;

            foreach (var availableShippingMethod in availableShippingMethods)
            {
                var price          = availableShippingMethod.GetPriceForCurrency(basket.BillingCurrency);
                var formattedprice = new Money((price == null ? 0 : price.Price), basket.BillingCurrency);

                shipping.AvailableShippingMethods.Add(new SelectListItem()
                {
                    Selected = shipping.SelectedShippingMethodId == availableShippingMethod.ShippingMethodId,
                    Text     = String.Format(" {0} ({1})", availableShippingMethod.Name, formattedprice),
                    Value    = availableShippingMethod.ShippingMethodId.ToString()
                });
            }

            shipping.ShippingCountry = shippingInformation.Country.Name;

            return(base.View("/Views/Shipping.cshtml", shipping));
        }
        public ActionResult Index()
        {
            var shippingModel = new ShippingViewModel();

            shippingModel.AvailableShippingMethods = new List <SelectListItem>();

            var shippingCountry          = TransactionLibrary.GetShippingInformation().Country;
            var availableShippingMethods = TransactionLibrary.GetShippingMethods(shippingCountry);

            var selectedShipping = TransactionLibrary.GetBasket(false).PurchaseOrder.Shipments.FirstOrDefault();

            foreach (var availableShippingMethod in availableShippingMethods)
            {
                shippingModel.AvailableShippingMethods.Add(new SelectListItem()
                {
                    Selected = selectedShipping != null &&
                               selectedShipping.ShippingMethod.ShippingMethodId ==
                               availableShippingMethod.ShippingMethodId,
                    Text  = availableShippingMethod.Name,
                    Value = availableShippingMethod.ShippingMethodId.ToString()
                });
            }

            return(View("/Views/Shipping.cshtml", shippingModel));
        }
Esempio n. 3
0
    private void PopulateShippingAddress(List <Country> countries)
    {
        var existingShipmentAddress = TransactionLibrary.GetShippingInformation();

        shippingFirstName.Text  = existingShipmentAddress.FirstName;
        shippingLastName.Text   = existingShipmentAddress.LastName;
        shippingEmail.Text      = existingShipmentAddress.EmailAddress;
        shippingCompany.Text    = existingShipmentAddress.CompanyName;
        shippingAttention.Text  = existingShipmentAddress.Attention;
        shippingStreet.Text     = existingShipmentAddress.Line1;
        shippingStreetTwo.Text  = existingShipmentAddress.Line2;
        shippingCity.Text       = existingShipmentAddress.City;
        shippingPostalCode.Text = existingShipmentAddress.PostalCode;
        shippingPhone.Text      = existingShipmentAddress.PhoneNumber;
        shippingMobile.Text     = existingShipmentAddress.MobilePhoneNumber;

        shippingCountry.DataSource = countries;
        shippingCountry.DataBind();

        if (billingAddress.Country != null)
        {
            shippingCountry.SelectedValue = existingShipmentAddress.Country.Id.ToString();
        }

        ShippingAddress = existingShipmentAddress;
    }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

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

            Country shippingCountry = TransactionLibrary.GetShippingInformation().Country;

            var availablePaymentMethods = TransactionLibrary.GetPaymentMethods(shippingCountry);

            var existingPayment = basket.Payments.FirstOrDefault();

            var selectedPaymentMethodId = existingPayment != null
                ? existingPayment.PaymentMethod.PaymentMethodId
                : -1;

            foreach (var availablePaymentMethod in availablePaymentMethods)
            {
                var option = new ListItem();
                option.Text     = availablePaymentMethod.Name;
                option.Value    = availablePaymentMethod.PaymentMethodId.ToString();
                option.Selected = availablePaymentMethod.PaymentMethodId == selectedPaymentMethodId;

                AvailablePaymentMethods.Items.Add(option);
            }
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            var paymentViewModel = new PaymentViewModel();

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

            Country shippingCountry = TransactionLibrary.GetShippingInformation().Country;

            var availablePaymentMethods = TransactionLibrary.GetPaymentMethods(shippingCountry);

            var existingPayment = basket.Payments.FirstOrDefault();

            paymentViewModel.SelectedPaymentMethodId = existingPayment != null
                                ? existingPayment.PaymentMethod.PaymentMethodId
                                : -1;

            foreach (var availablePaymentMethod in availablePaymentMethods)
            {
                var option = new SelectListItem();
                option.Text     = availablePaymentMethod.Name;
                option.Value    = availablePaymentMethod.PaymentMethodId.ToString();
                option.Selected = availablePaymentMethod.PaymentMethodId == paymentViewModel.SelectedPaymentMethodId;

                paymentViewModel.AvailablePaymentMethods.Add(option);
            }

            return(View("/Views/mc/Payment.cshtml", paymentViewModel));
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PurchaseOrderModel model = MapOrder();

            model.BillingAddress  = MapOrderAddress(TransactionLibrary.GetBillingInformation());
            model.ShippingAddress = MapOrderAddress(TransactionLibrary.GetShippingInformation());
            var basket          = UCommerce.Api.TransactionLibrary.GetBasket(false).PurchaseOrder;
            var billingCurrency = basket.BillingCurrency;

            foreach (var basketOrderLine in basket.OrderLines)
            {
                var orderLineModel = new OrderlineModel();

                orderLineModel.Sku         = basketOrderLine.Sku;
                orderLineModel.VariantSku  = basketOrderLine.VariantSku;
                orderLineModel.ProductName = basketOrderLine.ProductName;
                orderLineModel.Quantity    = basketOrderLine.Quantity;

                orderLineModel.Total = new UCommerce.Money(basketOrderLine.Total.GetValueOrDefault(), billingCurrency).ToString();

                model.OrderLines.Add(orderLineModel);
            }

            model.SubTotal      = GetMoneyFormat(basket.SubTotal.GetValueOrDefault(), billingCurrency);
            model.TaxTotal      = GetMoneyFormat(basket.TaxTotal.GetValueOrDefault(), billingCurrency);
            model.DiscountTotal = GetMoneyFormat(basket.DiscountTotal.GetValueOrDefault(), billingCurrency);
            model.ShippingTotal = GetMoneyFormat(basket.ShippingTotal.GetValueOrDefault(), billingCurrency);
            model.PaymentTotal  = GetMoneyFormat(basket.PaymentTotal.GetValueOrDefault(), billingCurrency);
            model.OrderTotal    = GetMoneyFormat(basket.OrderTotal.GetValueOrDefault(), billingCurrency);


            BuildPage(model);
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            var addressDetails = new AddressDetailsModel();

            var shippingInformation = TransactionLibrary.GetShippingInformation();
            var billingInformation  = TransactionLibrary.GetBillingInformation();

            BillingAddressFirstName.Text         = billingInformation.FirstName;
            BillingAddressLastName.Text          = billingInformation.LastName;
            BillingAddressEmailAddress.Text      = billingInformation.EmailAddress;
            BillingAddressPhoneNumber.Text       = billingInformation.PhoneNumber;
            BillingAddressMobilePhoneNumber.Text = billingInformation.MobilePhoneNumber;
            BillingAddressLine1.Text             = billingInformation.Line1;
            BillingAddressLine2.Text             = billingInformation.Line2;
            BillingAddressPostalCode.Text        = billingInformation.PostalCode;
            BillingAddressCity.Text        = billingInformation.City;
            BillingAddressAttention.Text   = billingInformation.Attention;
            BillingAddressCompanyName.Text = billingInformation.CompanyName;
            var billingAddressCountryId = billingInformation.Country != null ? billingInformation.Country.CountryId : -1;

            ShippingAddressFirstName.Text         = shippingInformation.FirstName;
            ShippingAddressLastName.Text          = shippingInformation.LastName;
            ShippingAddressEmailAddress.Text      = shippingInformation.EmailAddress;
            ShippingAddressPhoneNumber.Text       = shippingInformation.PhoneNumber;
            ShippingAddressMobilePhoneNumber.Text = shippingInformation.MobilePhoneNumber;
            ShippingAddressLine1.Text             = shippingInformation.Line1;
            ShippingAddressLine2.Text             = shippingInformation.Line2;
            ShippingAddressPostalCode.Text        = shippingInformation.PostalCode;
            ShippingAddressCity.Text        = shippingInformation.City;
            ShippingAddressAttention.Text   = shippingInformation.Attention;
            ShippingAddressCompanyName.Text = shippingInformation.CompanyName;
            var shippingAddressCountryId = shippingInformation.Country != null ? shippingInformation.Country.CountryId : -1;

            addressDetails.AvailableCountries = UCommerce.EntitiesV2.Country.All().ToList().Select(x => new ListItem()
            {
                Text = x.Name, Value = x.CountryId.ToString()
            }).ToList();

            BillingAddressCountryDropDown.ClearSelection();
            ShippingAddressCountryDropDown.ClearSelection();

            foreach (var country in addressDetails.AvailableCountries)
            {
                var shippingCountryIsSelected = shippingAddressCountryId.ToString() == country.Value;
                var billingCountryIsSelected  = billingAddressCountryId.ToString() == country.Value;
                ShippingAddressCountryDropDown.Items.Add(new ListItem {
                    Text = country.Text, Value = country.Value, Selected = shippingCountryIsSelected
                });
                BillingAddressCountryDropDown.Items.Add(new ListItem {
                    Text = country.Text, Value = country.Value, Selected = billingCountryIsSelected
                });
            }
        }
Esempio n. 8
0
        public ActionResult Index()
        {
            BasketViewModel model = MapOrder();

            model.BillingAddress  = MapOrderAddress(TransactionLibrary.GetBillingInformation());
            model.ShippingAddress = MapOrderAddress(TransactionLibrary.GetShippingInformation());

            return(View(model));
        }
Esempio n. 9
0
        public ActionResult Index()
        {
            PurchaseOrderViewModel model = MapOrder();

            model.BillingAddress  = MapOrderAddress(TransactionLibrary.GetBillingInformation());
            model.ShippingAddress = MapOrderAddress(TransactionLibrary.GetShippingInformation());

            return(View("/Views/mc/preview.cshtml", model));
        }
        public override ActionResult Index(ContentModel model)
        {
            var paymentViewModel = new PaymentViewModel();

            paymentViewModel.AvailablePaymentMethods = new List <SelectListItem>();

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

            Country shippingCountry = TransactionLibrary.GetShippingInformation().Country;

            var availablePaymentMethods = TransactionLibrary.GetPaymentMethods(shippingCountry);

            var existingPayment = basket.Payments.FirstOrDefault();

            paymentViewModel.SelectedPaymentMethodId = existingPayment != null
                ? existingPayment.PaymentMethod.PaymentMethodId
                : -1;

            foreach (var availablePaymentMethod in availablePaymentMethods)
            {
                var     option       = new SelectListItem();
                decimal feePercent   = availablePaymentMethod.FeePercent;
                var     fee          = availablePaymentMethod.GetFeeForCurrency(basket.BillingCurrency);
                var     formattedFee = new Money((fee == null ? 0 : fee.Fee), basket.BillingCurrency);

                option.Text = String.Format(" {0} ({1} + {2}%)", availablePaymentMethod.Name, formattedFee,
                                            feePercent.ToString("0.00"));
                option.Value    = availablePaymentMethod.PaymentMethodId.ToString();
                option.Selected = availablePaymentMethod.PaymentMethodId == paymentViewModel.SelectedPaymentMethodId;

                paymentViewModel.AvailablePaymentMethods.Add(option);
            }

            if (paymentViewModel.AvailablePaymentMethods.Any() && paymentViewModel.AvailablePaymentMethods.All(x => !x.Selected))
            {
                // Always make sure, that one payment method is selected.
                paymentViewModel.AvailablePaymentMethods.First().Selected = true;
            }

            paymentViewModel.ShippingCountry = shippingCountry.Name;

            return(View("/Views/Payment.cshtml", paymentViewModel));
        }
        public override ActionResult Index(RenderModel model)
        {
            var addressDetails = new AddressDetailsViewModel();

            var shippingInformation = TransactionLibrary.GetShippingInformation();
            var billingInformation  = TransactionLibrary.GetBillingInformation();

            addressDetails.BillingAddress.FirstName         = billingInformation.FirstName;
            addressDetails.BillingAddress.LastName          = billingInformation.LastName;
            addressDetails.BillingAddress.EmailAddress      = billingInformation.EmailAddress;
            addressDetails.BillingAddress.PhoneNumber       = billingInformation.PhoneNumber;
            addressDetails.BillingAddress.MobilePhoneNumber = billingInformation.MobilePhoneNumber;
            addressDetails.BillingAddress.Line1             = billingInformation.Line1;
            addressDetails.BillingAddress.Line2             = billingInformation.Line2;
            addressDetails.BillingAddress.PostalCode        = billingInformation.PostalCode;
            addressDetails.BillingAddress.City        = billingInformation.City;
            addressDetails.BillingAddress.State       = billingInformation.State;
            addressDetails.BillingAddress.Attention   = billingInformation.Attention;
            addressDetails.BillingAddress.CompanyName = billingInformation.CompanyName;
            addressDetails.BillingAddress.CountryId   = billingInformation.Country != null ? billingInformation.Country.CountryId : -1;

            addressDetails.ShippingAddress.FirstName         = shippingInformation.FirstName;
            addressDetails.ShippingAddress.LastName          = shippingInformation.LastName;
            addressDetails.ShippingAddress.EmailAddress      = shippingInformation.EmailAddress;
            addressDetails.ShippingAddress.PhoneNumber       = shippingInformation.PhoneNumber;
            addressDetails.ShippingAddress.MobilePhoneNumber = shippingInformation.MobilePhoneNumber;
            addressDetails.ShippingAddress.Line1             = shippingInformation.Line1;
            addressDetails.ShippingAddress.Line2             = shippingInformation.Line2;
            addressDetails.ShippingAddress.PostalCode        = shippingInformation.PostalCode;
            addressDetails.ShippingAddress.City        = shippingInformation.City;
            addressDetails.ShippingAddress.State       = shippingInformation.State;
            addressDetails.ShippingAddress.Attention   = shippingInformation.Attention;
            addressDetails.ShippingAddress.CompanyName = shippingInformation.CompanyName;
            addressDetails.ShippingAddress.CountryId   = shippingInformation.Country != null ? shippingInformation.Country.CountryId : -1;

            addressDetails.AvailableCountries = Country.All().ToList().Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.CountryId.ToString()
            }).ToList();

            return(base.View("/Views/BillingShippingAddress.cshtml", addressDetails));
        }
Esempio n. 12
0
        private void PopulateShippingAddress()
        {
            var shipmentAddress = TransactionLibrary.GetShippingInformation();

            litShippingName.Text       = shipmentAddress.FirstName + " " + shipmentAddress.LastName;
            litShippingCompany.Text    = shipmentAddress.CompanyName;
            litShippingStreet.Text     = shipmentAddress.Line1;
            litShippingPostalCode.Text = shipmentAddress.PostalCode;
            litShippingCity.Text       = shipmentAddress.City;
            litShippingCountry.Text    = shipmentAddress.Country.Name;

            if (!string.IsNullOrEmpty(shipmentAddress.Attention))
            {
                litShippingAttention.Text = $"att. {shipmentAddress.Attention}";
            }

            litShippingPhone.Text       = shipmentAddress.PhoneNumber;
            litShippingMobilePhone.Text = shipmentAddress.MobilePhoneNumber;
            lnkShippingMail.NavigateUrl = "mailto:" + shipmentAddress.EmailAddress;
            lnkShippingMail.Text        = shipmentAddress.EmailAddress;
        }
        public ActionResult Index()
        {
            var paymentModel = new PaymentViewModel();

            paymentModel.AvailablePaymentMethods = new List <SelectListItem>();

            var shippingCountry = TransactionLibrary.GetShippingInformation().Country;
            var payment         = TransactionLibrary.GetBasket(false).PurchaseOrder.Payments.FirstOrDefault();

            var availablePaymentMethods = TransactionLibrary.GetPaymentMethods(shippingCountry);

            foreach (var availablePaymentMethod in availablePaymentMethods)
            {
                paymentModel.AvailablePaymentMethods.Add(new SelectListItem()
                {
                    Selected = payment != null && payment.PaymentMethod.PaymentMethodId ==
                               availablePaymentMethod.PaymentMethodId,
                    Text  = availablePaymentMethod.Name,
                    Value = availablePaymentMethod.PaymentMethodId.ToString()
                });
            }

            return(View("/Views/Payment.cshtml", paymentModel));
        }
        private PurchaseOrderViewModel MapOrder()
        {
            PurchaseOrder basket = TransactionLibrary.GetBasket(false).PurchaseOrder;

            var basketModel = new PurchaseOrderViewModel();

            basketModel.BillingAddress  = TransactionLibrary.GetBillingInformation();
            basketModel.ShipmentAddress = TransactionLibrary.GetShippingInformation();

            foreach (var orderLine in basket.OrderLines)
            {
                var orderLineModel = new OrderlineViewModel();
                orderLineModel.ProductName = orderLine.ProductName;
                orderLineModel.Sku         = orderLine.Sku;
                orderLineModel.VariantSku  = orderLine.VariantSku;
                orderLineModel.Total       =
                    new Money(orderLine.Total.GetValueOrDefault(), orderLine.PurchaseOrder.BillingCurrency).ToString();
                orderLineModel.Tax =
                    new Money(orderLine.VAT, basket.BillingCurrency).ToString();
                orderLineModel.Price =
                    new Money(orderLine.Price, basket.BillingCurrency).ToString();
                orderLineModel.PriceWithDiscount =
                    new Money(orderLine.Price - orderLine.Discount, basket.BillingCurrency).ToString();
                orderLineModel.Quantity = orderLine.Quantity;
                orderLineModel.Discount = orderLine.Discount;

                basketModel.OrderLines.Add(orderLineModel);
            }

            basketModel.DiscountTotal  = new Money(basket.DiscountTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            basketModel.DiscountAmount = basket.DiscountTotal.GetValueOrDefault();
            basketModel.SubTotal       = new Money(basket.SubTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            basketModel.OrderTotal     = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            basketModel.TaxTotal       = new Money(basket.TaxTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            basketModel.ShippingTotal  = new Money(basket.ShippingTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();
            basketModel.PaymentTotal   = new Money(basket.PaymentTotal.GetValueOrDefault(), basket.BillingCurrency).ToString();


            var shipment = basket.Shipments.FirstOrDefault();

            if (shipment != null)
            {
                basketModel.ShipmentName   = shipment.ShipmentName;
                basketModel.ShipmentAmount = basket.ShippingTotal.GetValueOrDefault();
            }

            var payment = basket.Payments.FirstOrDefault();

            if (payment != null)
            {
                basketModel.PaymentName   = payment.PaymentMethodName;
                basketModel.PaymentAmount = basket.PaymentTotal.GetValueOrDefault();
            }

            ViewBag.RowSpan = 4;
            if (basket.DiscountTotal > 0)
            {
                ViewBag.RowSpan++;
            }
            if (basket.ShippingTotal > 0)
            {
                ViewBag.RowSpan++;
            }
            if (basket.PaymentTotal > 0)
            {
                ViewBag.RowSpan++;
            }

            return(basketModel);
        }