コード例 #1
0
        public ActionResult GetCards(SetsVM vm)
        {
            using (var context = new Context())
            {
                var setIdsToInclude = vm.Sets.Where(s => s.IncludeBlack || s.IncludeBlue || s.IncludeColorless || s.IncludeGreen ||
                                                    s.IncludeMulti || s.IncludeRed || s.IncludeWhite).Select(s => s.Id);
                var setsToInclude = context.Sets.Where(s => setIdsToInclude.Contains(s.Id)).ToList();

                var cards = setsToInclude.SelectMany(s => s.GetCardsWithColorIdentity(_getColorIdentitiesToInclude(vm, s.Id)));
                var model = new CardsVM
                {
                    Cards = cards.Select(c => new CardVM
                    {
                        Id       = c.Id,
                        Name     = c.Name,
                        Set      = c.Set.Name,
                        ManaCost = c.ManaCost,
                        Rarity   = c.Rarity,
                        Amount   = 0
                    }).OrderBy(c => c.Rarity).ToList()
                };

                return(View("Cards", model));
            }
        }
コード例 #2
0
        public static CardsVM ToViewModel(this Player p, bool red = false)
        {
            CardsVM c = new CardsVM();

            c.Id       = p.Id;
            c.Name     = p.Name;
            c.TeamName = p.TeamName;
            if (!red)
            {
                c.Total = p.YellowCards;
            }
            else
            {
                c.Total = p.RedCards;
            }
            return(c);
        }
コード例 #3
0
        public ActionResult GetCardsBySets(IEnumerable <int> setIds)
        {
            using (var context = new Context())
            {
                var sets  = context.Sets.Where(s => setIds.Contains(s.Id));
                var cards = sets.SelectMany(s => s.Cards);

                var model = new CardsVM
                {
                    Cards = cards.Select(c => new CardVM
                    {
                        Id       = c.Id,
                        Name     = c.Name,
                        Set      = c.Set.Name,
                        ManaCost = c.ManaCost,
                        Rarity   = c.Rarity,
                        Amount   = 0
                    }).ToList()
                };

                return(View("Cards", model));
            }
        }
コード例 #4
0
        public ActionResult Cards()
        {
            using (var context = new Context())
            {
                var collection = _getCollection(context);

                var model = new CardsVM();

                if (collection.Cards != null && collection.Cards.Count > 0)
                {
                    model.Cards = collection.Cards.Select(c => new CardVM
                    {
                        Id     = c.Card.Id,
                        Name   = c.Card.Name,
                        Set    = c.Card.Set.Name,
                        SetId  = c.Card.Set.Id,
                        Amount = c.Amount,
                        Price  = context.CardPricing.FirstOrDefault(cc => cc.Card.Id == c.Card.Id)?.Price
                    }).ToList();
                }

                return(View(model));
            }
        }
コード例 #5
0
ファイル: CardsPage.xaml.cs プロジェクト: Douk771/OlympGym
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     DataContext = new CardsVM();
 }
コード例 #6
0
ファイル: CardsPage.xaml.cs プロジェクト: Douk771/OlympGym
 public CardsPage()
 {
     InitializeComponent();
     DataContext = new CardsVM();
 }