예제 #1
0
        /// <summary>
        ///     Returns the OrderOverview page
        /// </summary>
        /// <returns>Actionresult OrderOverview</returns>
        public IActionResult Overview()
        {
            UserOrderViewModel model = new UserOrderViewModel();

            model.OrdersInSystem = new List <OrderViewModel>();
            foreach (Order o in orderRepo.RetrieveAllOrders())
            {
                IMapper        mapper = mapextension.OrdertoOrderViewModel();
                OrderViewModel omodel = mapper.Map <OrderViewModel>(o);
                omodel.ItemsInOrder = new List <CartItemViewModel>();
                omodel.User         = new UserOverviewViewModel();
                omodel.User.Email   = o.RetrieveCustomer().Email;

                foreach (CartItem c in o.RetrieveItemsInOrder())
                {
                    CartItemViewModel cmodel = new CartItemViewModel();
                    cmodel.Quantity = c.Quantity;
                    omodel.ItemsInOrder.Add(cmodel);
                }
                model.OrdersInSystem.Add(omodel);
            }
            return(View("OrderOverview", model));
        }