Beispiel #1
0
 public IEnumerable<OrderInfo> GetAll(int start, int pageSize)
 {
     var orders = GetAll();
     var customers = new CustomerRepository().GetAll().ToDictionary(c => c.CustomerID);
     var orderItems = new OrderItemRepository().GetAll().ToArray();
     var results = orders.Skip(start)
                         .Take(pageSize)
                         .Select(o => new
                         {
                             OrderID = o.OrderID,
                             OrderDate = o.OrderDate,
                             CustomerName = customers[o.CustomerID].Name,
                             CustomerID = o.CustomerID,
                             OrderItems = orderItems.Where(i => i.OrderID == o.OrderID)
                         })
                         .Select(o => new OrderInfo()
                         {
                             OrderID = o.OrderID,
                             OrderDate = o.OrderDate,
                             CustomerName = o.CustomerName,
                             CustomerID = o.CustomerID,
                             Total = o.OrderItems.Sum(i => i.Amount),
                             Status = BuildStatusName(o.OrderItems),
                             HasShippedItems = o.OrderItems.Any(i => i.OrderStatus() is ShippedState)
                         });
     return results.ToArray();
 }
Beispiel #2
0
        public IEnumerable <OrderInfo> GetAll(int start, int pageSize)
        {
            var orders     = GetAll();
            var customers  = new CustomerRepository().GetAll().ToDictionary(c => c.CustomerID);
            var orderItems = new OrderItemRepository().GetAll().ToArray();
            var results    = orders.Skip(start)
                             .Take(pageSize)
                             .Select(o => new
            {
                OrderID      = o.OrderID,
                OrderDate    = o.OrderDate,
                CustomerName = customers[o.CustomerID].Name,
                CustomerID   = o.CustomerID,
                OrderItems   = orderItems.Where(i => i.OrderID == o.OrderID)
            })
                             .Select(o => new OrderInfo()
            {
                OrderID         = o.OrderID,
                OrderDate       = o.OrderDate,
                CustomerName    = o.CustomerName,
                CustomerID      = o.CustomerID,
                Total           = o.OrderItems.Sum(i => i.Amount),
                Status          = BuildStatusName(o.OrderItems),
                HasShippedItems = o.OrderItems.Any(i => i.OrderStatus() is ShippedState)
            });

            return(results.ToArray());
        }
Beispiel #3
0
        public IEnumerable <Order> GetByProduct(long productID)
        {
            Debug.WriteLine("Executing EF Order.GetByProduct");
            var orderItems = new OrderItemRepository().GetAll().ToArray();

            return(Data.Values.Where(o => orderItems.Any(i => i.OrderID == o.OrderID &&
                                                         i.ProductID == productID))
                   .Select(Mapper.Map <Order, Order>).ToArray());
        }
Beispiel #4
0
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     var productsDataProxy = new ProductRepository();
     var inventoryDataProxy = new InventoryItemRepository();
     var customerDataProxy = new CustomerRepository();
     var orderItemDataProxy = new OrderItemRepository();
     var orderRepository = new OrderRepository(customerDataProxy, orderItemDataProxy);
     _inventoryService = new InventoryItemService(inventoryDataProxy);
     _orderItemsService = new OrderItemService(orderItemDataProxy, productsDataProxy, inventoryDataProxy, new DTCTransactionContext());
     _ordersService = new OrderService(orderRepository, _orderItemsService, new DTCTransactionContext());
     _customersService = new CustomerService(customerDataProxy, _ordersService);
     _productsService = new ProductService(productsDataProxy, _ordersService, _inventoryService, new DTCTransactionContext());
     _categoriesService = new CategoryService(new CategoryRepository(), _productsService);
     this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService);
 }
Beispiel #5
0
        public IEnumerable<Order> GetByProduct(long productID)
        {
            Debug.WriteLine("Executing EF Order.GetByProduct");
            var orderItems = new OrderItemRepository().GetAll().ToArray();

            return Orders.Where(o => orderItems.Any(i => i.OrderID == o.OrderID &&
                                                         i.ProductID == productID))
                         .Select(Mapper.Map<Order, Order>).ToArray();
        }