public DeleteOrderCommand(long orderID, IOrderDataProxy orderDataProxy, OrderItemService orderItemService, ITransactionContext transactionContext)
 {
     _orderID = orderID;
     _orderDataProxy = orderDataProxy;
     _orderItemService = orderItemService;
     _transactionContext = transactionContext;
 }
 public CustomerOrderWindow(OrderService orderService,
                            CustomerService customerService,
                            OrderItemService orderItemService,
                            InventoryItemService inventoryService,
                            MainWindowVM mainVM,
                            EventAggregator eventAggregator)
     : this()
 {
     var vm = new CustomerOrderVM(eventAggregator, orderService, orderItemService, inventoryService, mainVM);
     DataContext = vm;
 }
 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);
 }
Exemple #4
0
 private void ConfigureEFUsage()
 {
     var productsDataProxy = new DAL.EF.ProductRepository();
     var inventoryDataProxy = new DAL.EF.InventoryItemRepository();
     var customerDataProxy = new DAL.EF.CustomerRepository();
     var orderItemDataProxy = new DAL.EF.OrderItemRepository();
     var orderRepository = new DAL.EF.OrderRepository();
     var categoriesDataProxy = new DAL.EF.CategoryRepository();
     _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, orderRepository, _inventoryService, new DTCTransactionContext());
     _categoriesService = new CategoryService(categoriesDataProxy, productsDataProxy);
     this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService);
 }
 public CustomerOrderWindow(OrderVM currentOrder,
                            OrderService orderService,
                            CustomerService customerService,
                            OrderItemService orderItemService,
                            InventoryItemService inventoryService,
                            MainWindowVM mainVM,
                            EventAggregator eventAggregator)
     : this()
 {
     var order = new Order()
     {
         ID = currentOrder.ID,
         CustomerID = currentOrder.CustomerID,
         OrderDate = currentOrder.OrderDate,
     };
     var vm = new CustomerOrderVM(eventAggregator, order, orderService, orderItemService, inventoryService, mainVM);
     vm.RefreshCommand.Execute(null);
     DataContext = vm;
 }
        public void Is_valid_when_order_has_no_associated_order_items_that_have_been_shipped()
        {
            var orderID = 1;
            var orderItemDataProxy = new Mock<IOrderItemDataProxy>();
            orderItemDataProxy.Setup(p => p.GetByOrder(orderID))
                              .Returns((new[]
                                      {
                                         new OrderItem() { OrderStatusID = OrderStatusConstants.BACK_ORDERED_STATE },
                                         new OrderItem() { OrderStatusID = OrderStatusConstants.PENDING_STATUS }
                                      }).AsEnumerable<OrderItem>());
                                                                    
            var service = new OrderItemService(orderItemDataProxy.Object, 
                                               Mock.Of<IProductDataProxy>(), 
                                               Mock.Of<IInventoryItemDataProxy>(), 
                                               Mock.Of<ITransactionContext>());

            var rule = new ValidOrderStatusForUpdateRule(orderID, service);
            rule.Validate().IsValid.ShouldBe(true);
            rule.ErrorMessage.ShouldBe(null);
        }
        public async Task Is_invalid_when_order_has_any_associated_order_items_that_have_been_shipped_async()
        {
            var orderID = 1;
            var orderItemDataProxy = new Mock<IOrderItemDataProxy>();
            orderItemDataProxy.Setup(p => p.GetByOrderAsync(orderID))
                              .Returns(Task.FromResult((new[]
                                      {
                                         new OrderItem() { OrderStatusID = OrderStatusConstants.BACK_ORDERED_STATE },
                                         new OrderItem() { OrderStatusID = OrderStatusConstants.SHIPPED_STATUS }
                                      }).AsEnumerable<OrderItem>()));
                                                                    
            var service = new OrderItemService(orderItemDataProxy.Object, 
                                               Mock.Of<IProductDataProxy>(), 
                                               Mock.Of<IInventoryItemDataProxy>(), 
                                               Mock.Of<ITransactionContext>());

            var rule = new ValidOrderStatusForUpdateRule(orderID, service);
            await rule.ValidateAsync();
            rule.IsValid.ShouldBe(false);
            rule.ErrorMessage.ShouldNotBe(null);
        }
 public ValidOrderStatusForUpdateRule(long orderID, OrderItemService orderItemDataProxy)
 {
     _orderID            = orderID;
     _orderItemDataProxy = orderItemDataProxy;
 }
Exemple #9
0
 private void Setup(EventAggregator eventAggregator, OrderService orderService, OrderItemService orderItemService, InventoryItemService inventoryService, MainWindowVM mainVM)
 {
     _orderService              = orderService;
     _orderItemService          = orderItemService;
     _inventoryService          = inventoryService;
     _mainVM                    = mainVM;
     _eventAggregator           = eventAggregator;
     _orderItems                = new ObservableCollection <OrderItemVM>();
     _saveOrderCommand          = new Command(async() => await SaveAsync());
     _addOrderItemCommand       = new Command(() => AddOrderItem(), () => CanAdd);
     _deleteSelectedItemCommand = new Command(async() => await DeleteSelectedItemAsync());
     _submitOrderCommand        = new Command(async() => await SubmitAsync());
     _shipOrderCommand          = new Command(async() => await ShipAsync());
     _refreshCommand            = new Command(async() => await LoadOrderItemsAsync());
 }
Exemple #10
0
 public CustomerOrderVM(EventAggregator eventAggregator, Order order, OrderService orderService, OrderItemService orderItemService, InventoryItemService inventoryService, MainWindowVM mainVM)
     : base(order, orderService)
 {
     Setup(eventAggregator, orderService, orderItemService, inventoryService, mainVM);
 }
 public ValidOrderStatusForUpdateRule(long orderID, OrderItemService orderItemDataProxy)
 {
     _orderID = orderID;
     _orderItemDataProxy = orderItemDataProxy;
 }
Exemple #12
0
 public OrderController(CompanyDetailsService companyDetailsService, JobItemService jobItemService, OrderService orderService, OrderItemService orderItemService, CurrencyService currencyService, ListItemService listItemService)
 {
     _companyDetailsService = companyDetailsService;
     _jobItemService        = jobItemService;
     _orderService          = orderService;
     _orderItemService      = orderItemService;
     _listItemService       = listItemService;
     _currencyService       = currencyService;
 }
Exemple #13
0
        public void CreateOrdersFromPendingItems_ValidPendingOrderItems_OrdersCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var orderRepository          = new OrderRepository();
            var orderItemRepository      = new OrderItemRepository();
            var supplierRepository       = new SupplierRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();
            var companyDetailsRepository = new CompanyDetailsRepository();
            var consignmentRepository    = new ConsignmentRepository();

            var supplier1Id = Guid.NewGuid();
            var supplier2Id = Guid.NewGuid();
            var supplier3Id = Guid.NewGuid();
            var job1Id      = Guid.NewGuid();
            var job2Id      = Guid.NewGuid();
            var job3Id      = Guid.NewGuid();
            var jobItem1Id  = Guid.NewGuid();
            var jobItem2Id  = Guid.NewGuid();
            var jobItem3Id  = Guid.NewGuid();
            var jobItem4Id  = Guid.NewGuid();
            var jobItem5Id  = Guid.NewGuid();
            var jobItem6Id  = Guid.NewGuid();
            var jobItem7Id  = Guid.NewGuid();

            CreateOrdersFromPendingItemsHelper.CreateContextForPendingItemTests(
                job1Id, job2Id, job3Id, supplier1Id, supplier2Id, supplier3Id,
                jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id);
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);
            var listItemService   = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobItemService    = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);
            var orderItemService  = new OrderItemService(
                userContext, orderRepository, orderItemRepository, supplierRepository, jobItemRepository, listItemRepository, dispatcher);

            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem1Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier2Id, "some description", 1, "partno", "instructions", 30, jobItem2Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem3Id, 29.99m, 0m);

            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem4Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier2Id, "some description", 1, "partno", "instructions", 30, jobItem5Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier3Id, "some description", 1, "partno", "instructions", 30, jobItem6Id, 29.99m, 0m);

            orderItemService.CreatePending(Guid.NewGuid(), supplier3Id, "some description", 1, "partno", "instructions", 30, jobItem7Id, 29.99m, 0m);

            var orderService = new OrderService(
                userContext, orderRepository, consignmentRepository, supplierRepository, currencyRepository, entityIdProvider, orderItemService, companyDetailsRepository, dispatcher);

            orderService.CreateOrdersFromPendingItems();

            var orders = orderService.GetOrders().OrderBy(o => o.OrderNo).ToList();

            Assert.AreEqual(3, orders.Count);
            Assert.AreEqual("1", orders[0].OrderNo);
            Assert.AreEqual(supplier1Id, orders[0].Supplier.Id);
            Assert.AreEqual("2", orders[1].OrderNo);
            Assert.AreEqual(supplier2Id, orders[1].Supplier.Id);
            Assert.AreEqual("3", orders[2].OrderNo);
            Assert.AreEqual(supplier3Id, orders[2].Supplier.Id);

            var orderItems = orderItemService.GetOrderItems(orders[0].Id).OrderBy(oi => oi.ItemNo).ToList();

            Assert.AreEqual(3, orderItems.Count);
            Assert.AreEqual(jobItem1Id, orderItems[0].JobItem.Id);    // JR2000/1
            Assert.AreEqual(jobItem3Id, orderItems[1].JobItem.Id);    // JR2000/3
            Assert.AreEqual(jobItem4Id, orderItems[2].JobItem.Id);    // JR2001/1

            orderItems = orderItemService.GetOrderItems(orders[1].Id).OrderBy(oi => oi.ItemNo).ToList();
            Assert.AreEqual(2, orderItems.Count);
            Assert.AreEqual(jobItem2Id, orderItems[0].JobItem.Id);    // JR2000/2
            Assert.AreEqual(jobItem5Id, orderItems[1].JobItem.Id);    // JR2001/2

            orderItems = orderItemService.GetOrderItems(orders[1].Id).OrderBy(oi => oi.ItemNo).ToList();
            Assert.AreEqual(2, orderItems.Count);
            Assert.AreEqual(jobItem6Id, orderItems[0].JobItem.Id);    // JR2001/3
            Assert.AreEqual(jobItem7Id, orderItems[1].JobItem.Id);    // JR2002/1

            Assert.AreEqual(0, orderItemService.GetPendingOrderItems().Count());
        }
Exemple #14
0
 public static void Constructor_NullAccessor_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new OrderItemService(null));
 }
Exemple #15
0
 public static void DeleteOrderItem_NullOrder_ThrowsException(
     CatalogueItemId catalogueItemId,
     OrderItemService service)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => _ = service.DeleteOrderItem(null, catalogueItemId));
 }