Exemplo n.º 1
0
        private async void RemoveCoin(WindowCommandContext context)
        {
            try
            {
                if (SelectedCoin != null && await context.Window.ThrowWillBeRemovedMessageBox(SelectedCoin) == MessageDialogResult.Affirmative)
                {
                    var isFirst = Coins.FirstOrDefault() == SelectedCoin;
                    var current = SelectedCoin;
                    if (isFirst)
                    {
                        CoinsCollectionView.MoveCurrentToNext();
                    }
                    else
                    {
                        CoinsCollectionView.MoveCurrentToPrevious();
                    }

                    Coins.Remove(current);
                    _serializableCacheService.Remove(current);

                    CoinsCollectionView.Refresh();
                }
            }
            catch (Exception ex)
            {
                context.Window.ThrowUnknownErrorMessageBox(ex);
            }
        }
Exemplo n.º 2
0
        private void AddNewCoin(WindowCommandContext context)
        {
            try
            {
                Coins.Add(NewCoin);
                CoinsCollectionView.MoveCurrentTo(NewCoin);

                IsAddOpened = false;
                CoinsCollectionView.Refresh();
            }
            catch (Exception ex)
            {
                context.Window.ThrowUnknownErrorMessageBox(ex);
            }
        }
Exemplo n.º 3
0
        private async void SaveAll(WindowCommandContext context)
        {
            var invalidCoins = Coins.Where(x => !x.Validator.ValidateAll().IsValid)
                               .Select(x => x.Title)
                               .ToList();

            if (invalidCoins.Count == 0)
            {
                _serializableCacheService.Commit();
            }
            else
            {
                await context.Window.ThrowValidationFailedMessageBox(invalidCoins);
            }
        }
Exemplo n.º 4
0
 private bool CanRemoveCoin(WindowCommandContext context)
 {
     return(CoinsCollectionView.CurrentItem != null);
 }
Exemplo n.º 5
0
 private bool CanSaveAll(WindowCommandContext context)
 {
     return(!_serializableCacheService.IsEmpty);
 }