Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            _dataService = dataService;

            _dataService.GetRetNaklad(
                (item, error) =>
            {
                if (error != null)
                {
                    // Report error here
                    return;
                }

                ProductItemViewModelList = item.Naklad.ProductItemList;
                Comment      = item.Naklad.Comment;
                PaymentDelay = item.Naklad.PaymentDelay;
                PaymentType  = item.Naklad.PaymentType;
                DocN         = item.Naklad.DocN;
                DocDate      = item.Naklad.DocDate;
                DocTime      = item.Naklad.DocDate;
                Branch       = branchList.First(b => b.Id == item.Naklad.BranchId);
                Account      = accountList.First(b => b.Id == item.Naklad.AccountId);
                Store        = storeList.First(b => b.Id == item.Naklad.StoreId);
                Provider     = providerList.First(b => b.Id == item.Naklad.ProviderId);
                IsPosted     = item.Naklad.IsPosted;
            });

            SaveRetNakladCommand = new RelayCommand(
                () => _dataService.SaveRetNaklad(ReturnNaklad));

            PrintCommand = new RelayCommand(
                () => _dataService.PrintRetNaklad(ReturnNaklad));

            GetBranchListCommand   = new RelayCommand(GetBranchList);
            GetStoreListCommand    = new RelayCommand(GetStoreList);
            GetAccountListCommand  = new RelayCommand(GetAccountList);
            GetProviderListCommand = new RelayCommand(GetProviderList);
            //DeleteProductCommand = new RelayCommand<object>((s) => DeleteProduct(s));
            DeleteProductCommand  = new RelayCommand(DeleteProduct);
            AddProductCommand     = new RelayCommand(AddProduct);
            OpenProductCommand    = new RelayCommand(OpenProduct);
            SaveRetNakladCommand  = new RelayCommand(SaveRetNaklad);
            PrintRetNakladCommand = new RelayCommand(PrintRetNaklad);
            SelectedCellCommand   = new RelayCommand <SelectedCellsChangedEventArgs>(GetProducts);
            //CloseCommand = new RelayCommand<object>(o => ((Window)o).Close());
            CloseCommand = new RelayCommand <object>(CloseNaklad);

            Messenger.Default.Register <SummaMessage>
            (
                this,
                (action) => ReceiveMessage(action)
            );
        }