public IActionResult CustomerDetail()
        {
            if (CustomerViewModel.CurrentCustomer != null)
            {
                CustomerViewModel.CurrentCustomerOrderLines = new List <IOrderedEnumerable <OrderLine> >();
                CustomerViewModel.CurrentCustomerOrders     = _orderService.FindByCustomerIdResult(CustomerViewModel.CurrentCustomer.Id).OrderByDescending(o => o.CreatedAt);
                foreach (var order in CustomerViewModel.CurrentCustomerOrders)
                {
                    var orderLines = _orderLineService.FindByOrderId(order.Id).OrderBy(ol => ol.RentedAt);
                    CustomerViewModel.CurrentCustomerOrderLines.Add(orderLines);
                }

                return(View(CustomerViewModel));
            }
            else
            {
                CustomerViewModel.Error = "Geen klant geselecteerd. Kan geen details tonen";
            }
            return(RedirectToAction("Customers"));
        }
Exemplo n.º 2
0
        private void UpdateCustomerArticles()
        {
            CheckInViewModel.CustomerArticles = new List <Article>();

            var orders = _orderService.FindByCustomerIdResult(CheckInViewModel.SelectedCustomer.Id)
                         .Where(o => o.NumberOfOrderLines > 0 && !o.ReturnedAt.HasValue);

            foreach (var order in orders)
            {
                var orderLines = _orderLineService.FindByOrderId(order.Id)
                                 .Where(ol => !ol.ReturnedAt.HasValue);

                foreach (var orderLine in orderLines)
                {
                    var article = new Article();
                    article.Product      = new Product();
                    article.Id           = (Guid)orderLine.ArticleId;
                    article.Product.Name = orderLine.ProductName;
                    CheckInViewModel.CustomerArticles.Add(article);
                }
            }
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            try
            {
                _homeViewModel.NbrArticles  = _articleService.All().Count;
                _homeViewModel.NbrCustomers = _customerService.All().Count;
                _homeViewModel.NbrOrders    = 0;
                foreach (var order in _orderService.All())
                {
                    _homeViewModel.NbrOrders += _orderLineService.FindByOrderId(order.Id).Count;
                }

                _homeViewModel.NbrProducts = _productService.All().Count;
            }
            catch (Exception e)
            {
                return(RedirectToAction("ExceptionError"));
            }
            return(View(_homeViewModel));
        }