public PlaceOrderCommand(
     string userName, 
     Order order)
 {
     UserName = userName;
     Order = order;
 }
        public async Task<ActionResult> AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }

                await _bus.SendAsync(
                    new PlaceOrderCommand(User.Identity.Name,order));

                return RedirectToAction("Complete");
            }
            catch (Exception ex)
            {
                return View(order);
            }
        }
        public async Task<int> CreateOrderAsync(Order order)
        {
            _storeDb.Orders.Add(order);
            await _storeDb.SaveChangesAsync();

            decimal orderTotal = 0;

            var cartItems = GetCartItems();

            foreach (var item in cartItems)
            {
                var orderDetail = new OrderDetail
                {
                    AlbumId = item.AlbumId,
                    OrderId = order.OrderId,
                    UnitPrice = item.Album.Price,
                    Quantity = item.Count
                };

                orderTotal += (item.Count * item.Album.Price);

                _storeDb.OrderDetails.Add(orderDetail);
            }

            order.Total = orderTotal;
            _storeDb.SaveChanges();
            EmptyCart();

            return order.OrderId;
        }