Esempio n. 1
0
        public MainWindowViewModel(ICoinRepository coinRepository,
                                   IUnitOfWorkFactory unitOfWorkFactory,
                                   ICoinModelFactory coinModelFactory,
                                   IDirtySerializableCacheService serializableCacheService)
        {
            _coinModelFactory         = coinModelFactory;
            _serializableCacheService = serializableCacheService;

            RemoveCoinCommand          = new RelayCommand <WindowCommandContext>(RemoveCoin, CanRemoveCoin);
            ShowEditCoinControlCommand = new RelayCommand(ShowEditCoinControl, CanShowEditCoinControl);
            ShowAddCoinControlCommand  = new RelayCommand(ShowAddCoinControl);
            SaveAllCommand             = new RelayCommand <WindowCommandContext>(SaveAll, CanSaveAll);
            AddNewCoinCommand          = new RelayCommand <WindowCommandContext>(AddNewCoin);
            ToggleGroupingPanelCommand = new RelayCommand(ToggleGroupingPanel);

            _serializableCacheService.CacheChanged += CacheChangedHandler;

            using (unitOfWorkFactory.Create())
            {
                Coins.AddRange(coinRepository.GetAll().Select(x => _coinModelFactory.Create(x)));
            }

            CoinsCollectionView = CollectionViewSource.GetDefaultView(Coins);
            CoinsCollectionView.CurrentChanged += CoinsCollectionChangedHandler;
        }
Esempio n. 2
0
 private void Search()
 {
     Coins.Clear();
     Coins.AddRange((SearchText != null && SearchText.Trim() != string.Empty) ? SourceCoins.Where(c =>
                                                                                                  c.Name.Trim().ToLower().Contains(SearchText.ToLower()) ||
                                                                                                  c.Symbol.Trim().ToLower().Contains(SearchText.ToLower())) : LoadCoins(0));
 }
Esempio n. 3
0
        private async Task GetCoins()
        {
            IsBusy = true;
            try
            {
                var result = await RestRepository.GetCoins();

                result.Remove(result.First(c => BitcoinId.Equals(c.Id)));
                Coins.Clear();
                SourceCoins.Clear();
                SourceCoins.AddRange(result);
                Coins.AddRange(LoadCoins(0));
                if (!string.IsNullOrWhiteSpace(SearchText))
                {
                    Search();
                }
            } catch (Exception e)
            {
                Crashes.TrackError(e);
                await PageDialogService.DisplayAlertAsync("Error", e.Message, "OK");
            } finally
            {
                IsBusy = false;
            }
        }
 public void AddCoins(bool feeCoin = false, params ICoin[] coins)
 {
     Coins.AddRange(coins);
     if (feeCoin)
     {
         FeeCoins.AddRange(coins);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Deposit coins into vending machine
 /// </summary>
 /// <param name="coins">Coins.</param>
 public void AddCoins(List <Coin> coins)
 {
     //Sort the coins by denomination
     Coins.AddRange(coins.OrderByDescending(c => c.Denomination).ToList());
 }