Esempio n. 1
0
        public async Task <IActionResult> ShippingInformation(string id = null)
        {
            var userId = _userManager.GetUserId(User);
            var users  = _dbContext.Users.Include(x => x.ShippingInformations);
            var user   = users.FirstOrDefault(x => x.Id == Guid.Parse(userId));

            var model = new ShippingInformationViewModel();

            if (id != null)
            {
                var result = user.ShippingInformations.FirstOrDefault(x => x.Id == Guid.Parse(id));

                if (result != null)
                {
                    model.City        = result.City;
                    model.Country     = result.Country;
                    model.FirstName   = result.FirstName;
                    model.FlatNumber  = result.FlatNumber;
                    model.HouseNumber = result.HouseNumber;
                    model.Id          = result.Id.ToString();
                    model.LastName    = result.LastName;
                    model.Name        = result.Name;
                    model.PhoneNumber = result.PhoneNumber;
                    model.Street      = result.Street;
                    model.ZipCode     = result.ZipCode;
                }
            }

            return(View(model));
        }
        //
        // GET: /Checkout/
        public ActionResult Index()
        {
            if (!CheckoutSettings.CheckoutIsEnabled)
            {
                return(RedirectToAction("Index", "Home"));
            }

            String uniqueCacheKey = KeyCheckoutCacheLocation + Guid.NewGuid().ToString("N");

            CheckoutViewModel checkoutInstance = prepareCheckoutViewModel(uniqueCacheKey);

            //If there are no items to checkout
            if (!checkoutInstance.OrderLines.Any())
            {
                return(RedirectToAction("Index", "Home"));
            }

            CacheItem item = new CacheItem(uniqueCacheKey, checkoutInstance);

            MemoryCache.Default.Add(item, CheckoutSettings.CheckoutInstanceCachePolicy);

            ShippingInformationViewModel model = prepareShippingInformationViewModel(checkoutInstance);

            return(View("ShippingInformation", model));
        }
        private void SetShipAllValues(ShippingInformationViewModel shippingViewModel)
        {
            foreach (var lineViewModel in this.gridSource)
            {
                SetShipValues(shippingViewModel, lineViewModel);

                // don't copy the shipping charge
                lineViewModel.ShippingCharge = null;
                lineViewModel.Commit();
            }
        }
 public static Address GetAddress(this ShippingInformationViewModel shippingInformation)
 {
     return(new Address(
                shippingInformation.Address.Line1,
                shippingInformation.Address.City,
                shippingInformation.Address.State,
                shippingInformation.Address.Zip,
                shippingInformation.Address.Country,
                shippingInformation.Address.Line2,
                shippingInformation.Address.Line3));
 }
Esempio n. 5
0
        public async void Checkout_Valid_Cart_And_Shipping_Information_Calls_Order_Service()
        {
            var cart = TestDataProvider.Cart;
            var shippingInformationViewModel = new ShippingInformationViewModel();
            var controller = new CartController(productService.Object, orderService.Object);

            var result = await controller.Checkout(cart, shippingInformationViewModel);

            orderService.Verify(s => s.AddOrder(It.IsAny <Order>()), Times.Once);
            Assert.AreEqual("Completed", result.ViewName);
            Assert.IsTrue(result.ViewData.ModelState.IsValid);
        }
        private void OnDeliveryMethodButtonClick(int rowHandle)
        {
            if (rowHandle < 0 || rowHandle > this.gridSource.Count)
            {
                return;
            }

            LineLevelInformationViewModel viewModel = this.gridSource[rowHandle];

            if (string.Equals(gridView.FocusedColumn.FieldName, ColShip, StringComparison.OrdinalIgnoreCase))
            {
                ShippingInformationViewModel shippingViewModel = ShowShippingForm(rowHandle);

                if (shippingViewModel != null)
                {
                    // we clear the header...
                    this.ViewModel.ExecuteClearHeaderDelivery();

                    // ... set the values for the selected line
                    SetShipValues(shippingViewModel, viewModel);

                    // ...and switch everything to line level
                    foreach (LineLevelInformationViewModel lineViewModel in this.gridSource)
                    {
                        lineViewModel.Commit();
                    }

                    this.ResetControlBindings();
                }
            }

            if (string.Equals(gridView.FocusedColumn.FieldName, ColPickup, StringComparison.OrdinalIgnoreCase))
            {
                PickupInformationViewModel pickupViewModel = ShowPickupForm(rowHandle);

                if (pickupViewModel != null)
                {
                    // we clear the header...
                    this.ViewModel.ExecuteClearHeaderDelivery();

                    // ... set the values for the selected line
                    SetPickupValues(pickupViewModel, viewModel);

                    // ...and switch everything to line level
                    foreach (LineLevelInformationViewModel lineViewModel in this.gridSource)
                    {
                        lineViewModel.Commit();
                    }

                    this.ResetControlBindings();
                }
            }
        }
Esempio n. 7
0
        public async void Checkout_Empty_Cart_ModelState_Has_Errors()
        {
            var cart = new Cart();
            var shippingInformationViewModel = new ShippingInformationViewModel();
            var controller = new CartController(productService.Object, orderService.Object);

            var result = await controller.Checkout(cart, shippingInformationViewModel);

            orderService.Verify(s => s.AddOrder(It.IsAny <Order>()), Times.Never);
            Assert.AreEqual(string.Empty, result.ViewName);
            Assert.IsFalse(result.ViewData.ModelState.IsValid);
        }
        public ActionResult BillingInformation(BillingInformationViewModel model)
        {
            CacheItem cachedCheckoutInstance =
                MemoryCache.Default.GetCacheItem(model.InstanceKey);

            if (cachedCheckoutInstance != null)
            {
                CheckoutViewModel checkoutInstance = cachedCheckoutInstance.Value as CheckoutViewModel;

                if (checkoutInstance.InstanceKey != model.InstanceKey)
                {
                    throw new InvalidOperationException("Checkout key mismatch.");
                }

                if (nextButtonWasClicked())
                {
                    if (ModelState.IsValid)
                    {
                        applyBillinginformationToCheckoutInstance(checkoutInstance, model);

                        ReviewViewModel nextModel = prepareReviewViewModel(checkoutInstance);

                        return(View("Review", nextModel));
                    }


                    //Something failed

                    //Repopulate non-bound items
                    model.OrderLines      = checkoutInstance.OrderLines;
                    model.SalesTax        = checkoutInstance.SalesTax;
                    model.ShippingAddress = checkoutInstance.ShippingAddress;
                    model.ShippingCost    = checkoutInstance.ShippingCost;

                    return(View(model));
                }
                else if (previousButtonWasClicked())
                {
                    ModelState.Clear();

                    ShippingInformationViewModel previousModel = prepareShippingInformationViewModel(checkoutInstance);

                    return(View("ShippingInformation", previousModel));
                }
                else
                {
                    throw new InvalidOperationException("Unexpected navigation.");
                }
            }

            return(Content("CheckoutExpired"));
        }
        private static void SetShipValues(
            ShippingInformationViewModel fromShippingViewModel,
            LineLevelInformationViewModel toLineViewModel)
        {
            toLineViewModel.IsShipping         = true;
            toLineViewModel.DeliveryDate       = fromShippingViewModel.DeliveryDate;
            toLineViewModel.ShippingCharge     = fromShippingViewModel.ShippingCharge;
            toLineViewModel.ShippingMethodCode = fromShippingViewModel.ShippingMethod.Code;
            toLineViewModel.ShippingAddress    = fromShippingViewModel.ShippingAddress;

            // Remove pickup related data
            toLineViewModel.DeliveryStore = null;
        }
Esempio n. 10
0
        public async void Checkout_Invalid_ModelState_Does_Nothing()
        {
            var cart = TestDataProvider.Cart;
            var shippingInformationViewModel = new ShippingInformationViewModel();
            var controller = new CartController(productService.Object, orderService.Object);

            controller.ModelState.AddModelError("error", "error");

            var result = await controller.Checkout(cart, shippingInformationViewModel);

            orderService.Verify(s => s.AddOrder(It.IsAny <Order>()), Times.Never);
            Assert.AreEqual(string.Empty, result.ViewName);
            Assert.IsFalse(result.ViewData.ModelState.IsValid);
        }
Esempio n. 11
0
        public async Task <ViewResult> Checkout()
        {
            var viewModel = new ShippingInformationViewModel();

            if (!User.Identity.IsAuthenticated)
            {
                return(View(viewModel));
            }

            var user = await UserManager.FindByNameAsync(User.Identity.Name);

            var userInformation = userInformationService.GetUserInformation(user.Id);

            viewModel.Address = Mapper.Map <Address, AddressViewModel>(userInformation.Address);
            viewModel.Name    = user.UserName;
            viewModel.Email   = user.Email;

            return(View(viewModel));
        }
        public ShippingInformationViewModel GetShippingViewModel(IEnumerable <Address> availableAddresses)
        {
            var result = new ShippingInformationViewModel();

            if (availableAddresses != null && availableAddresses.Any())
            {
                result.AvailableAddresses = availableAddresses;
            }

            if (this.ShippingAddress != null)
            {
                //If the shipping address exists, we should also have these values.
                if (String.IsNullOrEmpty(this.Email))
                {
                    throw new InvalidOperationException("Null value for email unexpected.");
                }

                if (String.IsNullOrEmpty(this.PhoneNumber))
                {
                    throw new InvalidOperationException("Null value for phone number unexpected.");
                }

                //If the address was the result of a selected address the id will have a value, so we dont need to populate
                //view model fields
                if (this.ShippingAddress.AddressID == 0)
                {
                    result.AddressLine1 = this.ShippingAddress.AddressLine1;
                    result.AddressLine2 = this.ShippingAddress.AddressLine2;
                    result.City         = this.ShippingAddress.City;
                    result.State        = this.ShippingAddress.State;
                    result.PostalCode   = this.ShippingAddress.PostalCode;
                }

                result.Email       = this.Email;
                result.PhoneNumber = this.PhoneNumber;
            }

            result.CartItems = this.CartItems;

            result.CheckoutInstance = this.CheckoutInstance;

            return(result);
        }
        private void OnShipAll_Click(object sender, EventArgs e)
        {
            ShippingInformationViewModel vm = ShowShippingForm();

            if (vm != null)
            {
                try
                {
                    this.SetShipAllValues(vm);
                    vm.CommitHeaderChanges();

                    this.ResetControlBindings();
                }
                catch (InvalidOperationException ex)
                {
                    SalesOrder.InternalApplication.Services.Dialog.ShowMessage(ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private ShippingInformationViewModel prepareShippingInformationViewModel(CheckoutViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            ShippingInformationViewModel result = new ShippingInformationViewModel();

            result.OrderLines = model.OrderLines;

            if (model.ShippingAddress != null)
            {
                result.EmailAddress = model.EmailAddress;

                result.PhoneNumber = model.PhoneNumber;

                result.ShippingAddress = model.ShippingAddress;
            }
#if DEBUG
            if (model.ShippingAddress == null)
            {
                result.EmailAddress = "*****@*****.**";

                result.PhoneNumber = "123-456-7890";

                result.ShippingAddress = new AddressViewModel()
                {
                    AddressLine1 = "123 Address st.",
                    AddressLine2 = "apt 2",
                    City         = "SomeCity",
                    State        = StateCode.NY,
                    PostalCode   = "12345"
                };
            }
#endif
            result.InstanceKey = model.InstanceKey;

            result.SalesTax = model.SalesTax;

            return(result);
        }
Esempio n. 15
0
        public async Task <IActionResult> ShippingInformation(ShippingInformationViewModel model)
        {
            var userId = _userManager.GetUserId(User);
            var users  = _dbContext.Users.Include(x => x.ShippingInformations);
            var user   = users.FirstOrDefault(x => x.Id == Guid.Parse(userId));

            if (user.ShippingInformations.Any(x => x.Name.ToLower().CompareTo(model.Name.ToLower()) == 0))
            {
                ModelState.AddModelError(string.Empty, _localizer["Name must be unique"]);
            }

            if (ModelState.IsValid)
            {
                var entity = model.Id == null ? new ShippingInformation() : user.ShippingInformations.FirstOrDefault(x => x.Id == Guid.Parse(model.Id));

                entity.City        = model.City;
                entity.Country     = model.Country;
                entity.FirstName   = model.FirstName;
                entity.FlatNumber  = model.FlatNumber;
                entity.HouseNumber = model.HouseNumber;
                entity.LastName    = model.LastName;
                entity.Name        = model.Name;
                entity.PhoneNumber = model.PhoneNumber;
                entity.Street      = model.Street;
                entity.ZipCode     = model.ZipCode;

                if (model.Id == null)
                {
                    user.ShippingInformations.Add(entity);
                }

                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(RedirectToAction(nameof(AccountController.Index), new { message = _localizer["Shipping information has been saved"] }));
                }
            }

            return(View(model));
        }
Esempio n. 16
0
        public formShippingInformation(ShippingInformationViewModel viewModel)
            : this()
        {
            this.dateTimePicker.MinDate = DateTime.Today;

            // Handle the formatting and parsing for binding to the DateTimePicker so it knows how to handle nulls from a DateTime? value.
            this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Format += new ConvertEventHandler(OnDateTimePicker_Format);
            this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Parse  += new ConvertEventHandler(OnDateTimePicker_Parse);

            // Toggle the charge button's text based on whether or not there is a charge
            this.btnChargeChange.DataBindings[DATABINDING_TEXTPROPERTY].Format += new ConvertEventHandler(OnShippingChargeButtonText_Format);

            // Bind to view model
            this.bindingSource.Add(viewModel);

            if (viewModel != null && viewModel.Transaction != null)
            {
                this.viewAddressUserControl1.SetProperties(viewModel.Transaction.Customer, viewModel.ShippingAddress);
            }

            viewModel.PropertyChanged += new PropertyChangedEventHandler(OnViewModel_PropertyChanged);
        }
        public ActionResult ShippingInformation(ShippingInformationViewModel model)
        {
            CacheItem cachedCheckoutInstance =
                MemoryCache.Default.GetCacheItem(model.InstanceKey);

            if (cachedCheckoutInstance != null)
            {
                CheckoutViewModel checkoutInstance = cachedCheckoutInstance.Value as CheckoutViewModel;

                if (checkoutInstance.InstanceKey != model.InstanceKey)
                {
                    throw new InvalidOperationException("Checkout key mismatch.");
                }

                if (nextButtonWasClicked())
                {
                    if (ModelState.IsValid)
                    {
                        applyShippingInformationToCheckoutInstance(checkoutInstance, model);

                        BillingInformationViewModel nextModel = prepareBillingInformationViewModel(checkoutInstance);

                        return(View("BillingInformation", nextModel));
                    }

                    //Something failed

                    //Repopulate non bound items
                    model.OrderLines = checkoutInstance.OrderLines;
                    model.SalesTax   = checkoutInstance.SalesTax;

                    return(View(model));
                }

                throw new InvalidOperationException("Unexpected navigation.");
            }

            return(Content("CheckoutExpired"));
        }
        public formShippingInformation(ShippingInformationViewModel viewModel)
            : this()
        {
            this.dateTimePicker.MinDate    = DateTime.Today;
            this.labelShipMethodValue.Text = string.Empty;

            // Handle the formatting and parsing for binding to the DateTimePicker so it knows how to handle nulls from a DateTime? value.
            this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Format += new ConvertEventHandler(OnDateTimePicker_Format);
            this.dateTimePicker.DataBindings[DATABINDING_VALUEPROPERTY].Parse  += new ConvertEventHandler(OnDateTimePicker_Parse);

            // Toggle the charge button's text based on whether or not there is a charge
            this.btnChargeChange.DataBindings[DATABINDING_TEXTPROPERTY].Format += new ConvertEventHandler(OnShippingChargeButtonText_Format);

            // Bind to view model
            this.bindingSource.Add(viewModel);

            if (viewModel != null && viewModel.Transaction != null)
            {
                this.viewAddressUserControl1.SetProperties(viewModel.Transaction.Customer, viewModel.ShippingAddress);
                StoreDataManager storeDataManager = new StoreDataManager(
                    SalesOrder.InternalApplication.Settings.Database.Connection,
                    SalesOrder.InternalApplication.Settings.Database.DataAreaID);
                DAC       odac = new DAC(SalesOrder.InternalApplication.Settings.Database.Connection);
                DataTable dt   = odac.GetLineDataOV(viewModel.Transaction.TransactionId, viewModel.Transaction.TerminalId, viewModel.Transaction.StoreId, "1");
                if (dt.Rows.Count > 0)
                {
                    string DelMode = dt.Rows[0]["SHIPMODE"].ToString();


                    if (DelMode != "")
                    {
                        this.ViewModel.ShippingMethod = this.ViewModel.ShippingMethods.First(s => s.Code == DelMode);
                    }
                }
            }

            viewModel.PropertyChanged += new PropertyChangedEventHandler(OnViewModel_PropertyChanged);
        }
        private ShippingInformationViewModel ShowShippingForm(int rowIndex)
        {
            LineLevelInformationViewModel viewModel = null;

            if (rowIndex >= 0 && rowIndex < this.gridSource.Count)
            {
                viewModel = this.gridSource[rowIndex];
            }

            ShippingInformationViewModel vm = null;

            // Load any existing values
            if (viewModel != null)
            {
                vm = new ShippingInformationViewModel(this.ViewModel.Transaction, viewModel.LineItem);
                vm.DeliveryDate    = viewModel.DeliveryDate;
                vm.ShippingCharge  = viewModel.ShippingCharge;
                vm.ShippingMethod  = vm.ShippingMethods.FirstOrDefault(m => m.Code == viewModel.ShippingMethodCode);
                vm.ShippingAddress = viewModel.ShippingAddress;
            }
            else
            {
                vm = new ShippingInformationViewModel(this.ViewModel.Transaction, null);
            }
            vm.IsDeliveryChangeAllowed = this.ViewModel.IsDeliveryChangeAllowed;

            using (formShippingInformation frmShip = new formShippingInformation(vm))
            {
                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(frmShip);

                if (frmShip.DialogResult == DialogResult.OK)
                {
                    return(frmShip.ViewModel);
                }
            }

            return(null);
        }
Esempio n. 20
0
        public async Task <ViewResult> Checkout(Cart cart, ShippingInformationViewModel viewModel)
        {
            if (!cart.Items.Any())
            {
                ModelState.AddModelError(string.Empty, "Koszyk jest pusty");
            }

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var address = viewModel.GetAddress();
            var order   = new Order
            {
                Address     = address,
                CartLines   = cart.Items.ToList(),
                ClientName  = viewModel.Name,
                GiftWrap    = viewModel.GiftWrap,
                ClientEmail = viewModel.Email,
                OrderDate   = DateTime.UtcNow
            };

            if (User.Identity.IsAuthenticated)
            {
                var user = await UserManager.FindByNameAsync(User.Identity.Name);

                order.UserInformationId = user.Id;
            }

            await orderService.AddOrder(order);

            Session.ClearCart();

            return(View("Completed"));
        }
        //[AllowAnonymous]
        public ActionResult ProcessCart(string accion, ShippingInformationViewModel model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            int customerId = !User.Identity.IsAuthenticated ? 0 : Convert.ToInt32((User.Identity as ClaimsIdentity).FindFirst(ClaimTypes.NameIdentifier.ToString()).Value);
            //var lstItemsSerialized = (User.Identity as ClaimsIdentity).FindFirst(ClaimTypes.UserData.ToString()).Value;

            Order order = new Order()
            {
                CustomerId          = customerId,
                ShippingInformation = new ShippingInformation
                {
                    CrediCardType       = model.CrediCardType,
                    CreditCardHolder    = model.CreditCardHolder,
                    CreditCardNumber    = model.CreditCardNumber,
                    CrediCardExpiration = model.CrediCardExpiration,
                    Names           = model.Names,
                    LastNames       = model.LastNames,
                    ShippingAddress = model.ShippingAddress,
                    City            = model.City,
                    State           = model.State,
                    Zip             = model.Zip,
                    Country         = model.Country
                }
            };

            var answerOrder = IoCFactoryBusiness.Resolve <IOrdersService>().ProcessOrder(order);

            if (answerOrder)
            {
                var lstItemsSerialized = JsonSerializer.SerializeObject(new List <Item>());

                //Guardar en memoria
                var claims = new List <Claim>();

                var thumbClaim = (User.Identity as ClaimsIdentity).FindFirst(ClaimTypes.UserData.ToString());
                if (thumbClaim != null)
                {
                    (User.Identity as ClaimsIdentity).RemoveClaim(thumbClaim);
                }
                (User.Identity as ClaimsIdentity).AddClaim(new Claim(ClaimTypes.UserData, lstItemsSerialized));

                claims = (User.Identity as ClaimsIdentity).Claims.ToList();
                var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                if (User.Identity.IsAuthenticated)
                {
                    AuthenticationManager.SignIn(new AuthenticationProperties()
                    {
                        IsPersistent = false
                    }, id);
                }

                ModelState.AddModelError("mensajeError", "Orden procesada correctamente");
            }
            else
            {
                ModelState.AddModelError("mensajeError", "No se pudo procesar la orden");
            }

            return(View("ShoppingCarts"));
        }
        public ActionResult ProcessCart()
        {
            ShippingInformationViewModel model = new ShippingInformationViewModel();

            return(View(model));
        }
        private void applyShippingInformationToCheckoutInstance(CheckoutViewModel checkoutInstance, ShippingInformationViewModel model)
        {
            if (checkoutInstance == null)
            {
                throw new ArgumentNullException("checkoutInstance");
            }

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (checkoutInstance.InstanceKey != model.InstanceKey)
            {
                throw new InvalidOperationException("Checkout key mismatch.");
            }

            checkoutInstance.EmailAddress = model.EmailAddress.Trim();

            checkoutInstance.PhoneNumber = model.PhoneNumber.Trim();

            if (checkoutInstance.ShippingAddress == null)
            {
                checkoutInstance.ShippingAddress = new AddressViewModel();
            }

            checkoutInstance.ShippingAddress.AddressLine1 = model.ShippingAddress.AddressLine1.Trim();
            checkoutInstance.ShippingAddress.AddressLine2 = model.ShippingAddress.AddressLine2.Trim();
            checkoutInstance.ShippingAddress.City         = model.ShippingAddress.City.Trim();
            checkoutInstance.ShippingAddress.State        = model.ShippingAddress.State;
            checkoutInstance.ShippingAddress.PostalCode   = model.ShippingAddress.PostalCode.Trim();

            checkoutInstance.ShippingCost = _shippingService.CalculateShipping(checkoutInstance.OrderLines);
        }
        public ActionResult ShippingInformation(ShippingInformationViewModel model)
        {
            CheckoutViewModel checkoutModel;

            if (CacheHelpers.GetCheckoutInstanceFromCache(model.CheckoutInstance, this.ControllerContext, out checkoutModel) != CacheHelpers.CheckoutCacheStatus.Success)
            {
                return(RedirectToAction("Index", "ShoppingCart"));
            }

            if (ModelState.IsValid)
            {
                Address shippingAddress;

                //If the user selected an address
                if (model.SelectedShippingAddressId > 0)
                {
                    var address = _addressService.Get(model.SelectedShippingAddressId);

                    //Verify it exists
                    if (address != null)
                    {
                        //Verify it belongs to this user
                        if (address.UserID == IdentityHelpers.GetUserId(this.User.Identity))
                        {
                            shippingAddress = address;
                        }
                        else
                        {
                            throw new InvalidOperationException("Address does not belong to this user.");
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("Expected address, but not found.");
                    }
                }
                else
                {
                    shippingAddress = new Address {
                        AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, City = model.City, PostalCode = model.PostalCode, State = model.State
                    }
                };

                checkoutModel.Email = model.Email;

                checkoutModel.PhoneNumber = model.PhoneNumber;

                checkoutModel.ShippingAddress = shippingAddress;

                checkoutModel.ShippingCost = _orderService.CalculateShipping(checkoutModel.CartItems);

                checkoutModel.Tax = _orderService.CalculateTax(checkoutModel.CartItems);

                var nextModel = checkoutModel.GetBillingViewModel();

                #region Test Information
#if DEBUG
                nextModel.CreditCardPayment = new CreditCardPaymentViewModel()
                {
                    //Authorize.Net Test Visa
                    CreditCardNumber = "4007000000027",
                    CVV             = "123",
                    ExpirationMonth = 1,
                    ExpirationYear  = 2018
                };

                nextModel.BillingSameAsShipping = true;
#endif
                #endregion

                ModelState.Clear();

                return(View("BillingInformation", nextModel));
            }
            else
            {
                //Resupply unbound information the model needs to redisplay
                checkoutModel.GetShippingViewModel(_userService
                                                   .GetUserWithAddresses(IdentityHelpers.GetUserId(User.Identity)).Addresses);

                return(View(model));
            }
        }