Ejemplo n.º 1
0
        private void RemoveCommandExecute(object o)
        {
            HierarchicalResultViewModel vm = Hierarchical.Selected;

            if (vm == null)
            {
                return;
            }

            ICardCollection sourceCollection = _magicDatabase.GetAllCollections().First(cc => cc.Name == Hierarchical.Name);

            InputViewModel questionViewModel = InputViewModelFactory.Instance.CreateQuestionViewModel("Remove", string.Format("Remove selected from {0}?", sourceCollection.Name));

            OnInputRequested(questionViewModel);

            if (questionViewModel.Result == true)
            {
                using (_magicDatabaseForCardInCollection.BatchMode())
                {
                    foreach (ICardInCollectionCount cicc in GetCardInCollectionInSelected(vm, sourceCollection))
                    {
                        ICardCount cardCount = new CardCount();
                        foreach (KeyValuePair <ICardCountKey, int> kv in cicc.GetCardCount())
                        {
                            cardCount.Add(kv.Key, -kv.Value);
                        }

                        _magicDatabaseForCardInCollection.InsertOrUpdateCardInCollection(sourceCollection.Id, cicc.IdGatherer, cicc.IdLanguage, cardCount);
                    }
                }

                LoadCardsHierarchy();
            }
        }
Ejemplo n.º 2
0
        protected override void OkCommandExecute(object o)
        {
            foreach (CardCollectionInputGraphicViewModel card in _cards.Where(c => c.ChangedCount != 0))
            {
                CardCount cardCount = new CardCount();
                cardCount.Add(new CardCountKey(Foil, AltArt), card.ChangedCount);

                _magicDatabase.InsertOrUpdateCardInCollection(CardCollection.Id, card.Card.IdGatherer, InputLanguage.Id, cardCount);
            }

            RefreshDisplayedData(true);
            HasChange = false;
        }
Ejemplo n.º 3
0
 internal void Add(ICardCountKey key, int number)
 {
     _cardCount.Add(key, number);
 }