public async Task <IActionResult> Index() { OrderViewModel orderViewModel = new OrderViewModel(); var user = _identitySvc.Get(HttpContext.User); var cart = await _cartSvc.GetCart(user.Email); if (cart.Items.Any()) { CartTicket cartTicket = cart.Items[0]; Event catalogEvent = await _eventManagementSvc.GetEvent(cartTicket.EventId); //var order = _cartSvc.MapCartToOrder(cart); ViewBag.StripePublishableKey = paymentSettings.StripePublicKey; //return View(order); orderViewModel.EventName = catalogEvent.Name; orderViewModel.EventDate = catalogEvent.StartDate; orderViewModel.Location = catalogEvent.Place.Address + " " + catalogEvent.Place.City + " " + catalogEvent.Place.State + " " + catalogEvent.Place.ZipCode; orderViewModel.Price = catalogEvent.Price; orderViewModel.Quantity = cartTicket.TicketsPurchased; orderViewModel.TotalAmount = orderViewModel.Quantity * orderViewModel.Price; } return(View(orderViewModel)); }
//[HttpPost] public async Task <IActionResult> Index(int eventId) { var catalogEvent = await eventManagementService.GetEvent(eventId); var viewModel = new CartViewModel { Items = new CartEvent { Items = new List <CartEventItem> { new CartEventItem { Event = catalogEvent } } } }; return(View(viewModel)); }
public async Task <IActionResult> Index(string action) { if (action == "[ Checkout ]") { return(RedirectToAction("Index", "order")); } var vm = new CartListModel { EventsInCart = new List <Event>() }; try { var user = identitySvc.Get(HttpContext.User); var cart = await cartSvc.GetCart(user.Email); if (cart.Items != null) { foreach (var cartItem in cart.Items) { var catalogEvent = await eventManagementService.GetEvent(cartItem.EventId); catalogEvent.TicketsInCart = cartItem.TicketsPurchased; catalogEvent.ImageURL = ApiPaths.Image.GetImageUrl(imageServiceBaseUrl, catalogEvent.ImageURL); catalogEvent.DisplayPrice = catalogEvent.PriceType == EventPriceType.Free ? "Free" : ("$ " + catalogEvent.Price.ToString()); vm.EventsInCart.Add(catalogEvent); vm.Total += cartItem.TicketsPurchased * catalogEvent.Price; } } } catch (BrokenCircuitException) { // Catch error when CartApi is in open circuit mode ViewBag.IsBasketInoperative = true; } return(View(vm)); }
public async Task <IActionResult> EventDetails(int id) { var catalogEvent = await eventManagementService.GetEvent(id); return(View(catalogEvent)); }