public ActionResult IndexPost(string Action, CheckoutIndexViewModel Model) { _shoppingCartService.SetProperty("BillingAddressId", Model.BillingAddressId); _shoppingCartService.SetProperty("ShippingAddressId", Model.ShippingAddressId); _shoppingCartService.SetProperty("ShippingProviderId", Model.ShippingProviderId); switch (Action) { case "EditShippingAddress": return(RedirectToAction("EditAddress", "Customer", new { area = "OShop", id = Model.ShippingAddressId, ReturnUrl = Url.Action("Index", "Checkout", new { area = "OShop" }) })); case "RemoveShippingAddress": _shoppingCartService.RemoveProperty("ShippingAddressId"); return(RedirectToAction("RemoveAddress", "Customer", new { area = "OShop", id = Model.ShippingAddressId, ReturnUrl = Url.Action("Index", "Checkout", new { area = "OShop" }) })); case "EditBillingAddress": return(RedirectToAction("EditAddress", "Customer", new { area = "OShop", id = Model.BillingAddressId, ReturnUrl = Url.Action("Index", "Checkout", new { area = "OShop" }) })); case "RemoveBillingAddress": _shoppingCartService.RemoveProperty("RemoveBillingAddress"); return(RedirectToAction("RemoveAddress", "Customer", new { area = "OShop", id = Model.BillingAddressId, ReturnUrl = Url.Action("Index", "Checkout", new { area = "OShop" }) })); case "Validate": return(ValidateAddress()); default: return(Index()); } }
// GET: Chekout public ActionResult Index() { var model = new CheckoutIndexViewModel(); //preencher model.Carrinho = GetCarrinho(); return(View(model)); }
// GET: Checkout public ActionResult Index() { var model = new CheckoutIndexViewModel(); model.Carrinho = GetCarrinhoDaSessao(); return(View(model)); }
public ActionResult Incrementa(int id) { var model = new CheckoutIndexViewModel(); model.Carrinho = GetCarrinho(); model.Carrinho.Incrementa(id); //Session["Carrinho"] = model.Carrinho; return(RedirectToAction("Index")); }
public ActionResult Decrementa(int id) { var model = new CheckoutIndexViewModel(); //preencher model.Carrinho = GetCarrinho(); model.Carrinho.Decrementa(id); return(RedirectToAction("Index")); }
public ActionResult Remover(int id) { var model = new CheckoutIndexViewModel(); //preencher model.Carrinho = GetCarrinho(); model.Carrinho.Remove(id); // Session["Carrinho"] = model.Carrinho; return(RedirectToAction("Index")); }
// This method will be used by GET /Index/ and POST /ProcessPayment/ private IActionResult _Index(Payment payment = null) { var cart = HttpContext.Session.Get <Cart>("Cart"); CheckoutIndexViewModel viewModel = new CheckoutIndexViewModel(); // ensure cart is created if (cart == null) { cart = new Cart(); HttpContext.Session.Set <Cart>("Cart", cart); } viewModel.Cart = cart; // cannot proceed to check out if there are remaining seats left unfilled if (cart.HasRemainingSeatsLeft()) { TempData["danger"] = "Before you enter the checkout, please complete your seating arrangement first"; return(RedirectToAction("Index", "Cart")); } if (cart.Bookings != null && cart.Bookings.Any()) { var movieIds = cart.Bookings.Select(b => b.Show.MovieId).Distinct().ToArray(); var movies = _db.Movies.Include(m => m.Images).Where(m => movieIds.Contains(m.Id)).ToList(); if (movies != null && movies.Any()) { viewModel.Movies = movies; } var cinemaIds = cart.Bookings.Select(b => b.Show.CinemaId).Distinct().ToArray(); var cinemas = _db.Cinemas.Where(c => cinemaIds.Contains(c.Id)).ToList(); if (cinemas != null && cinemas.Any()) { viewModel.Cinemas = cinemas; } var showIds = cart.Bookings.Select(b => b.ShowId).Distinct().ToArray(); var shows = _db.Shows.Where(s => showIds.Contains(s.Id)).ToList(); if (shows != null && shows.Any()) { viewModel.Shows = shows; } } if (payment != null) { viewModel.Payment = payment; } return(View("Index", viewModel)); }
public IActionResult Index() { string pay_status = HttpContext.Session.GetString("PayStatus"); if (pay_status == "paid" || HttpContext.Session.GetInt32("OrderId") == null) { return(RedirectToAction("Index", "Home")); } int orderid = (int)HttpContext.Session.GetInt32("OrderId"); List <OrderDetail> orderdetails = _context.OrderDetails.Where(o => o.Order_Id == orderid).ToList(); List <Product> products = new List <Product>(); foreach (var detail in orderdetails) { Product pro = _context.Products.Where(o => o.Id == detail.Product_Id).FirstOrDefault(); products.Add(pro); } CheckoutIndexViewModel vm = new CheckoutIndexViewModel() { OrderDetails = orderdetails, Products = products, ProductTypes = _context.ProductTypes.ToList(), productBrands = _context.ProductBrands.ToList() }; int sum = 0; foreach (var detail in vm.OrderDetails) { sum += detail.PriceTotal; } HttpContext.Session.SetString("TongTien", sum.ToString()); PayPalConfig payPalConfig = PayPalService.GetPayPalConfig(); ViewBag.payPalConfig = payPalConfig; return(View(vm)); }
ActionResult RenderIndexView(CheckoutStageContext checkoutStageContext, PersistedCheckoutContext persistedCheckoutContext, PaymentMethodInfo selectedPaymentMethod, Customer customer, bool termsAndConditionsAccepted, string returnUrl, bool showCheckoutStageErrors) { var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); // Build a model and render it var billingAddressViewModel = customer.PrimaryBillingAddress != null ? AddressViewModelConverter.ConvertToAddressViewModel(customer.PrimaryBillingAddress, customer) : null; var shippingAddressViewModel = customer.PrimaryShippingAddress != null ? AddressViewModelConverter.ConvertToAddressViewModel(customer.PrimaryShippingAddress, customer) : null; var cartPageAd = new PayPalAd(PayPalAd.TargetPage.Cart); var gatewayIsTwoCheckout = AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWTWOCHECKOUT && selectedPaymentMethod != null && selectedPaymentMethod.Name == AppLogic.ro_PMCreditCard; var shippingEnabled = checkoutStageContext.ShippingAddress.Disabled != true || checkoutStageContext.ShippingMethod.Disabled != true; var shippingInfoRequired = checkoutStageContext.ShippingAddress.Required == true || checkoutStageContext.ShippingMethod.Required == true; var displayBillingSection = checkoutStageContext.BillingAddress.Disabled != true; // nal //var allowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"); var allowShipToDifferentThanBillTo = true; // Display the shipping section only if shipping is enabled on the site. If so, than if shipping can be different // than billing, we need to show the form. If shipping and billing can be different or the current payment // option doesn't care about billing, then show just the shipping section and that address will be used for // both shipping and billing. var displayShippingSection = shippingEnabled && allowShipToDifferentThanBillTo; var checkoutIsOffsiteOnly = PaymentOptionProvider.CheckoutIsOffsiteOnly(customer, cart); var paymentMethodStageState = ConvertStageStatusToDisplayState(checkoutStageContext.PaymentMethod, showCheckoutStageErrors); var model = new CheckoutIndexViewModel( selectedPaymentMethod: selectedPaymentMethod, selectedBillingAddress: billingAddressViewModel, selectedShippingAddress: shippingAddressViewModel, checkoutButtonDisabled: checkoutStageContext.PlaceOrderButton.Fulfilled != true, showOver13Required: Over13Required(customer), showOkToEmail: AppLogic.AppConfigBool("Checkout.ShowOkToEmailOnCheckout"), showTermsAndConditions: AppLogic.AppConfigBool("RequireTermsAndConditionsAtCheckout"), displayGiftCardSetup: checkoutStageContext.GiftCardSetup.Required == true, showOrderOptions: cart.AllOrderOptions.Any(), // nal //showOrderNotes: !AppLogic.AppConfigBool("DisallowOrderNotes"), showOrderNotes: true, showRealTimeShippingInfo: AppLogic.AppConfigBool("RTShipping.DumpDebugXmlOnCheckout") && (customer.IsAdminUser || customer.IsAdminSuperUser), allowShipToDifferentThanBillTo: allowShipToDifferentThanBillTo, displayShippingSection: displayShippingSection, displayBillingSection: displayBillingSection, shippingInfoIsRequired: shippingInfoRequired, displayTwoCheckoutText: gatewayIsTwoCheckout, displayContinueOffsite: selectedPaymentMethod != null && selectedPaymentMethod.Location == PaymentMethodLocation.Offsite, // nal //showPromotions: AppLogic.AppConfigBool("Promotions.Enabled"), showPromotions: true, // nal //showGiftCards: AppLogic.AppConfigBool("GiftCards.Enabled"), showGiftCards: true, giftCardCoversTotal: cart.GiftCardCoversTotal(), checkoutIsOffsiteOnly: checkoutIsOffsiteOnly, pageTitle: "Secure Checkout", payPalBanner: cartPageAd.Show ? cartPageAd.ImageScript : null, accountStageState: ConvertStageStatusToDisplayState(checkoutStageContext.Account, showCheckoutStageErrors), // nal continueShoppingUrl: Url.Content(returnUrl), offsiteCheckoutError: checkoutIsOffsiteOnly && paymentMethodStageState == CheckoutStageDisplayState.Failing ? "Please choose a payment method" : string.Empty, paymentMethodStageState: paymentMethodStageState, billingAddressStageState: ConvertStageStatusToDisplayState(checkoutStageContext.BillingAddress, showCheckoutStageErrors), shippingAddressStageState: ConvertStageStatusToDisplayState(checkoutStageContext.ShippingAddress, showCheckoutStageErrors), shippingMethodStageState: ConvertStageStatusToDisplayState(checkoutStageContext.ShippingMethod, showCheckoutStageErrors), giftCardSetupStageState: ConvertStageStatusToDisplayState(checkoutStageContext.GiftCardSetup, showCheckoutStageErrors)) { Over13Selected = persistedCheckoutContext.Over13Checked, OkToEmailSelected = customer.OKToEMail, TermsAndConditionsAccepted = termsAndConditionsAccepted }; return(View(model)); }