private OrderViewModel CreateOrderViewModel(decimal amtBeforeTaxes, ShoppingCart cart)
        {
            var viewModel = new OrderViewModel();
            {
                viewModel.ProvModel = RegisterLists.ProvList();
                viewModel.CountryModel = RegisterLists.CountryList();
                viewModel.CreditCardType = RegisterLists.CreditCardTypeList();
                viewModel.ExpiryYearList = RegisterLists.ExpiryYearList();
                viewModel.ExpiryMonthList = RegisterLists.ExpiryMonthList();


                if (User.Identity.IsAuthenticated)
                {
                    var currentUserId = User.Identity.GetUserId();
                    var currentUser = _context.Users.FirstOrDefault(x => x.Id == currentUserId);
                    CheckOutServices.PopulateViewModelWithRegisteredUserData(ref viewModel, currentUser);
                }


                if (amtBeforeTaxes == 0)
                    viewModel.IsPromo = true;

                if (viewModel.IsPromo)
                {
                    viewModel.CreditCardNumber = "4024007108173500";
                    viewModel.ExpiryMonthCreditCard = "04";
                    viewModel.ExpiryYearCreditCard = "2020";
                    viewModel.FirstNameCreditCard = "xxxxxx";
                    viewModel.LastNameCreditCard = "xxxxxx";
                }

                viewModel.CurrencyCode = _currencyCode;
                viewModel.PaymentType = "Sale";
                viewModel.Tax1Rate = _tax1Rate;
                viewModel.Tax1Name = _tax1Name;

                viewModel.Cart = cart;
            }
            return viewModel;
        }
示例#2
0
 public static ShoppingCart GetCart(HttpContextBase context)
 {
     var cart = new ShoppingCart();
     cart.ShoppingCartId = cart.GetCartId(context);
     return cart;
 }