// // GET: /ShoppingCart/ public ActionResult Index() { var cart = ShoppingCart.GetCart(db, HttpContext); var items = cart.GetCartItems(); var itemsCount = items.Sum(x => x.Count); //var subTotal = items.Sum(x => x.Count * x.Product.Price); //var shipping = itemsCount * (decimal)5.00; //var tax = (subTotal + shipping) * (decimal)0.05; //var total = subTotal + shipping + tax; //var costSummary = new OrderCostSummary //{ // CartSubTotal = subTotal.ToString("C"), // CartShipping = shipping.ToString("C"), // CartTax = tax.ToString("C"), // CartTotal = total.ToString("C") //}; var costSummary = shippingTaxCalculator.CalculateCost(items, null); // Set up our ViewModel var viewModel = new ShoppingCartViewModel { CartItems = items, CartCount = itemsCount, OrderCostSummary = costSummary }; // Track cart review event with measurements telemetry.TrackTrace("Cart/Server/Index"); // Return the view return(View(viewModel)); }
// // GET: /ShoppingCart/ public IActionResult Index() { var cart = ShoppingCart.GetCart(_db, this.productsRepository, HttpContext); var items = cart.GetCartItems(); var itemsCount = items.Sum(x => x.Count); var subTotal = items.Sum(x => x.Count * x.Product.Price); var shipping = itemsCount * (decimal)5.00; var tax = (subTotal + shipping) * (decimal)0.05; var total = subTotal + shipping + tax; var costSummary = new OrderCostSummary { CartSubTotal = subTotal.ToString("C"), CartShipping = shipping.ToString("C"), CartTax = tax.ToString("C"), CartTotal = total.ToString("C") }; // Set up our ViewModel var viewModel = new ShoppingCartViewModel { CartItems = items, CartCount = itemsCount, OrderCostSummary = costSummary }; // Track cart review event with measurements _telemetry.TrackTrace("Cart/Server/Index"); // Return the view return(View(viewModel)); }
private async Task MessageHandler(ProcessMessageEventArgs args) { telemetryProvider.TrackTrace("Trace Receiver"); string body = args.Message.Body.ToString(); try { action.ReceiveMessage(body); await args.CompleteMessageAsync(args.Message); } catch (Exception ex) { Console.WriteLine($"Unable to process message {ex}"); await args.AbandonMessageAsync(args.Message); } }
public async Task <ActionResult> Details(int?id) { if (id == null) { _telemetry.TrackTrace("Order/Server/NullId"); return(RedirectToAction("Index", new { invalidOrderSearch = Request.QueryString["id"] })); } var order = await _ordersQuery.FindOrderAsync(id.Value); var username = User.Identity.GetUserName(); // If the username isn't the same as the logged in user, return as if the order does not exist if (order == null || !String.Equals(order.Username, username, StringComparison.Ordinal)) { _telemetry.TrackTrace("Order/Server/UsernameMismatch"); return(RedirectToAction("Index", new { invalidOrderSearch = id.ToString() })); } // Capture order review event for analysis var eventProperties = new Dictionary <string, string>() { { "Id", id.ToString() }, { "Username", username } }; var costSummary = new OrderCostSummary() { CartSubTotal = 0.ToString("C"), CartShipping = 0.ToString("C"), CartTax = 0.ToString("C"), CartTotal = 0.ToString("C"), }; if (order.OrderDetails == null) { _telemetry.TrackEvent("Order/Server/NullDetails", eventProperties, null); } else { var eventMeasurements = new Dictionary <string, double>() { { "LineItemCount", order.OrderDetails.Count } }; _telemetry.TrackEvent("Order/Server/Details", eventProperties, eventMeasurements); costSummary = _shippingTaxCalc.CalculateCost(order.OrderDetails, order.PostalCode); //var itemsCount = order.OrderDetails.Sum(x => x.Count); //var subTotal = order.OrderDetails.Sum(x => x.Count * x.Product.Price); //var shipping = itemsCount * (decimal)6.00; //var tax = (subTotal + shipping) * (decimal)0.06; //var total = subTotal + shipping + tax; //costSummary.CartSubTotal = subTotal.ToString("C"); //costSummary.CartShipping = shipping.ToString("C"); //costSummary.CartTax = tax.ToString("C"); //costSummary.CartTotal = total.ToString("C"); } var viewModel = new OrderDetailsViewModel { OrderCostSummary = costSummary, Order = order }; return(View(viewModel)); }