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)); }
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)); }
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; }