Exemplo n.º 1
0
        public string InsertPreconstructedDeckCardsInDb(string url, PreconstructedDeckImporter preconstructedDeckImporter)
        {
            string html = _webAccess.GetHtml(url);

            DeckInfo deckInfo = preconstructedDeckImporter.ParseDeckPage(html);

            if (deckInfo == null)
            {
                return(null);
            }

            MagicDatabase.InsertNewPreconstructedDeck(deckInfo.IdEdition, deckInfo.Name, url);
            IPreconstructedDeck preconstructedDeck = MagicDatabase.GetPreconstructedDeck(deckInfo.IdEdition, deckInfo.Name);

            foreach (DeckCardInfo deckCardInfo in deckInfo.Cards)
            {
                if (deckCardInfo.NeedToCreate)
                {
                    int idGatherer = MagicDatabase.InsertNewCardEditionWithFakeGathererId(deckCardInfo.IdEdition, deckCardInfo.IdCard, deckCardInfo.IdRarity, deckCardInfo.PictureUrl);
                    MagicDatabase.InsertOrUpdatePreconstructedDeckCardEdition(preconstructedDeck.Id, idGatherer, deckCardInfo.Number);
                }
                else
                {
                    MagicDatabase.InsertOrUpdatePreconstructedDeckCardEdition(preconstructedDeck.Id, deckCardInfo.IdGatherer, deckCardInfo.Number);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public void PreconstructedDeckToCollection(IPreconstructedDeck preconstructedDeck, ICardCollection collection, ILanguage language)
        {
            using (new WriterLock(_lock))
            {
                if (preconstructedDeck == null || collection == null || language == null)
                {
                    return;
                }
                ICollection <IPreconstructedDeckCardEdition> deckComposition = GetPreconstructedDeckCards(preconstructedDeck);
                if (deckComposition == null || deckComposition.Count == 0)
                {
                    return;
                }
                int idLanguage = language.Id;

                using (BatchMode())
                {
                    foreach (IPreconstructedDeckCardEdition card in deckComposition)
                    {
                        CardCount cardCount = new CardCount
                        {
                            { CardCountKeys.Standard, card.Number }
                        };

                        InsertOrUpdateCardInCollection(collection.Id, card.IdGatherer, idLanguage, cardCount);
                    }
                }
            }
        }
        public PreconstructedDeckViewModel(IPreconstructedDeck preconstructedDeck, IEdition edition, IEnumerable <KeyValuePair <CardViewModel, int> > cards)
        {
            PreconstructedDeck = preconstructedDeck;
            Name     = preconstructedDeck.Name;
            _edition = edition;
            IDictionary <CardViewModel, int> temp = new Dictionary <CardViewModel, int>();

            foreach (KeyValuePair <CardViewModel, int> kv in cards)
            {
                temp.Add(kv);
            }
            Composition = new ReadOnlyDictionary <CardViewModel, int>(temp);
        }
Exemplo n.º 4
0
        public ICollection <IPreconstructedDeckCardEdition> GetPreconstructedDeckCards(IPreconstructedDeck preconstructedDeck)
        {
            if (preconstructedDeck == null)
            {
                return(null);
            }

            return(GetPreconstructedDeckCards(preconstructedDeck.Id));
        }
Exemplo n.º 5
0
 private void InsertInReferential(IPreconstructedDeck preconstructedDeck)
 {
     _preconstructedDecks.Add(preconstructedDeck.Id, preconstructedDeck);
 }