Esempio n. 1
0
        public IActionResult Index()
        {
            OrderHomeViewModel orderHomeViewModel = new OrderHomeViewModel();

            if (this.IsLoggedIn())
            {
                Order order = this.orderService
                              .GetCurrentActiveOrderByCashierId(this.User.Id);
                if (order == null)
                {
                    return(this.View(orderHomeViewModel));
                }
                orderHomeViewModel = order.ProjectTo <OrderHomeViewModel>();

                orderHomeViewModel.Products.Clear();

                foreach (var orderProduct in order.Products)
                {
                    ProductHomeViewModel productHomeViewModel = orderProduct.Product.ProjectTo <ProductHomeViewModel>();

                    orderHomeViewModel.Products.Add(productHomeViewModel);
                }
            }

            return(this.View(orderHomeViewModel));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var orderHomeViewModel = new OrderHomeViewModel();

            if (this.IsLoggedIn())
            {
                var activeOrder = this.orderService
                                  .GetActiveOrderByCashierId(User.Id);

                orderHomeViewModel = activeOrder.To <OrderHomeViewModel>();

                orderHomeViewModel.Products.Clear();

                foreach (var orderProduct in activeOrder.Products)
                {
                    ProductHomeViewModel productHomeViewModel = orderProduct
                                                                .Product
                                                                .To <ProductHomeViewModel>();

                    orderHomeViewModel.Products.Add(productHomeViewModel);
                }
            }

            return(this.View(orderHomeViewModel));
        }
Esempio n. 3
0
        public HttpResponse Index()
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.View());
            }
            else
            {
                var productsToShow = this.ordersService.GetActiveOrderProducts(this.User);

                var viewModel = new OrderHomeViewModel
                {
                    Products = productsToShow
                };

                return(this.View(viewModel, "IndexLoggedIn"));
            }
        }
 public OrderHomeView(OrderHomeViewModel view_model)
 {
     InitializeComponent();
     DataContext = view_model;
 }