public ShoppingCartViewModel()
        {
            Orders = new ObservableCollection <IOrder>();
            Eventaggregator.GetEvent <AddItemToCart>().Subscribe(BuildOrder);
            NavigateToProductsCommand = new RelayCommand(() => RegionManager.RequestNavigate(RegionNames.RightPaneRegion, new Uri("ProductsView", UriKind.Relative)));
            RemoveEntryCommand        = new RelayCommand <OrderEntry>(entry => currentOrder.Entries.Remove(entry));
            PlaceOrderCommand         = new RelayCommand <Order>(PlaceOrder);

            dataService = new InfoCaptureDataService();
            Orders      = dataService.GetAllOrders(InfoCaptureDataService.CurrentUser.CustomerID);
        }
        public ProductsViewModel()
        {
            var dataService = new InfoCaptureDataService();

            Products = dataService.GetAllProducts();

            AddItemToCartCommand = new RelayCommand <IProduct>(product => {
                if (product.Stock > 0)
                {
                    product.Stock -= 1;
                }
                RegionManager.RequestNavigate(RegionNames.RightPaneRegion, new Uri("ShoppingCartView", UriKind.Relative));
                Eventaggregator.GetEvent <AddItemToCart>().Publish(product);
            });

            viewSource = CollectionViewSource.GetDefaultView(Products);
            viewSource.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
            viewSource.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending));

            ViewSource = viewSource;
        }
예제 #3
0
파일: AppData.cs 프로젝트: bianliu1013/R3D
        public void AddandActiveDocument(IRDocument doc, bool setactive)
        {
            string typeName = doc.GetType().ToString();
            Type   docTy;

            if (!_documentTypesLoaded.TryGetValue(typeName, out docTy))
            {
                _documentTypesLoaded.Add(typeName, doc.GetType());
                doc.CreateDocumentSpecificRibbonTabs();
                doc.CreateDocumentSpecificTools();
                LoadExternalToolsFromPlugin(typeName);
            }

            _documents.Add(doc);

            Eventaggregator.GetEvent <NewDocumentAddedEvent>().Publish(doc);

            if (setactive)
            {
                ActiveDocument = doc;
            }
        }
예제 #4
0
        private void Login()
        {
            var dataService = new InfoCaptureDataService();

            Trace.TraceInformation(String.Format("{0} : Attempting to login", DateTime.Now));

            var customer = dataService.FindCustomer(CustomerName);

            if (customer != null)
            {
                Eventaggregator.GetEvent <LoginCompleted>().Publish(customer.FirstName);
                InfoCaptureDataService.CurrentUser = customer;
                RegionManager.RequestNavigate(RegionNames.RightPaneRegion, new Uri("ProductsView", UriKind.Relative));

                Trace.TraceInformation(String.Format("{0} : Login successful", DateTime.Now));
            }
            else
            {
                Error = "Login Failed, Try again!";

                Trace.TraceInformation(String.Format("{0} : Login failed", DateTime.Now));
            }
        }
예제 #5
0
 public ShellViewModel()
 {
     Eventaggregator.GetEvent <LoginCompleted>().Subscribe(customer => this.CurrentUser = new InfoCaptureDataService().FindCustomer(customer));
     NavigateToShoppingCartViewCommand = new RelayCommand(() => RegionManager.RequestNavigate(RegionNames.RightPaneRegion, new Uri("ShoppingCartView", UriKind.Relative)));
 }