コード例 #1
0
        public IActionResult SaveOrder(int orderId)
        {
            int sum = 0;

            foreach (OrderedOutfit ob in orderedOutfitRepository.GetOrderedOutfits(orderId))
            {
                var Outfit = OutfitRepository.Get(ob.OutfitId);
                sum += Outfit.Price * ob.Quantity;
            }
            Order newOrder = orderRepository.GetOrder(orderId);

            newOrder.Price = sum;
            orderRepository.EditOrder(newOrder);


            if (order.Lines == null)
            {
                orderRepository.RemoveOrder(orderId);
                orderedOutfitRepository.RemoveOrderedOutfits(orderId);
            }
            else
            {
                orderedOutfitRepository.RemoveOrderedOutfits(orderId);
                orderedOutfitRepository.AddOrderedOutfits(order.Lines, orderId);
            }



            return(RedirectToAction("UserOrders"));
        }
コード例 #2
0
        public async Task <IActionResult> Order(string userName)
        {
            Customer customer = await userManager.FindByNameAsync(userName);

            Cart cart = GetCart();

            Order order = OrderRepository.AddOrder(cart, customer);

            orderedOutfitRepository.AddOrderedOutfits(cart.Lines, order.Id);
            cart.Clear();
            return(RedirectToAction("UserOrders", "Order"));
        }