public IActionResult Index() { List <Address> addresses = customerSession.GetLoggedInCustomer() .Addresses.ToList(); return(View(addresses)); }
public IActionResult Index([FromForm] CreditCard creditCard) { if (ModelState.IsValid) { List <CartItem> cartItems = cartCookieManager.GetCookieData(); foreach (var cartItem in cartItems) { cartItem.Product = productRepository.GetProduct(cartItem.Id); } Customer loggedInCustomer = customerSession.GetLoggedInCustomer(); ShippingInformation selectedShippingRate = shippingInfoCookieManager.GetCookieData() .Find(s => s.IsSelected == true); Address selectedAddress = addressRepository.GetAddress(selectedShippingRate.SelectedAddressId); dynamic transactionResult = pagarMeManager.GenerateCreditCardPayment(loggedInCustomer, selectedShippingRate, selectedAddress, cartItems, creditCard); // return new ContentResult{ Content = $"OK! Transaction ID = {transactionResult.TransactionId}" }; return(new ContentResult { Content = "OK!" }); } return(Index()); }
public void OnAuthorization(AuthorizationFilterContext context) { customerSession = (CustomerSession)context.HttpContext.RequestServices.GetService(typeof(CustomerSession)); Customer customerFromSession = customerSession.GetLoggedInCustomer(); if (customerFromSession == null) { context.Result = new RedirectToActionResult("Login", "Home", new { area = "Customer" }); } }
public IActionResult Index() { var cartItems = cartCookieManager.GetCookieData(); var shippingInfos = shippingInfoCookieManager.GetCookieData(); if (cartItems.Count == 0 || shippingInfos.Count == 0) { return(RedirectToAction("Index", "Cart")); } ViewData["DestinationCep"] = shippingInfos[0].DestinationCep; List <Address> addresses = customerSession.GetLoggedInCustomer().Addresses.ToList(); return(View(addresses)); }