Exemplo n.º 1
0
        private IList <PreconstructedDeckViewModel> LoadReferentialData()
        {
            List <PreconstructedDeckViewModel> ret = new List <PreconstructedDeckViewModel>();
            IDictionary <int, CardViewModel>   allCardsViewModel = _magicDatabase.GetAllInfos().ToDictionary(cai => cai.IdGatherer, cai => new CardViewModel(cai));

            foreach (IPreconstructedDeck preconstructedDeck in _magicDatabase.GetAllPreconstructedDecks())
            {
                ICollection <IPreconstructedDeckCardEdition> deckComposition = _magicDatabase.GetPreconstructedDeckCards(preconstructedDeck);
                IEdition edition = _magicDatabase.GetEditionById(preconstructedDeck.IdEdition);

                ret.Add(new PreconstructedDeckViewModel(preconstructedDeck, edition,
                                                        deckComposition.Select(pdce => new KeyValuePair <CardViewModel, int>(allCardsViewModel[pdce.IdGatherer], pdce.Number))));
            }

            ret.Sort((x, y) =>
            {
                //Most recent set first
                if (!x.EditionDate.HasValue)
                {
                    return(y.EditionDate.HasValue ? 1 : 0);
                }
                if (!y.EditionDate.HasValue)
                {
                    return(-1);
                }
                int comp = y.EditionDate.Value.CompareTo(x.EditionDate.Value);
                if (comp == 0)
                {
                    //Alphabet order
                    comp = x.Name.CompareTo(y.Name);
                }


                return(comp);
            });

            return(ret.AsReadOnly());
        }
Exemplo n.º 2
0
 internal IEnumerable <CardViewModel> SearchResultAsViewModel()
 {
     return(_magicDatabase.GetAllInfos().Where(cai => CheckPerimeter(cai) && CheckName(cai) && CheckEdition(cai) && CheckColor(cai) && CheckType(cai) && CheckSubType(cai))
            .Select(cai => new CardViewModel(cai)));
 }
Exemplo n.º 3
0
 public static IEnumerable <IEdition> GetAllEditionIncludingCardOrdered(this IMagicDatabaseReadOnly magicDatabase, ICard card)
 {
     return(magicDatabase.GetAllInfos().GetAllEditionIncludingCardOrdered(card));
 }