Ejemplo n.º 1
0
 public CardResponse GetCard(string id)
 {
     return((from Print in this.__context.Print
             join cf in this.__context.CardFaces on Print.Card.Id equals cf.card.Id
             join pf in this.__context.PrintFace on Print.Id equals pf.PrintId
             join iu in this.__context.ImagesUrl on pf.id equals iu.printFace.id
             let mana = (from Costs in this.__context.Costs
                         from CostSymbols in this.__context.CostSymbols
                         join SymbolsInCosts in this.__context.SymbolsInCosts on Costs.id equals SymbolsInCosts.cost.id
                         where Costs.id == cf.manaCost.id && SymbolsInCosts.symbol.id == CostSymbols.id
                         select CostSymbols
                         ).ToList()
                        let typeLine = (from TypesInLine in this.__context.TypesInLine
                                        join Types in this.__context.Types on TypesInLine.type.id equals Types.id
                                        join TypeLine in this.__context.TypeLine on TypesInLine.line.id equals TypeLine.id
                                        join CardFaces in this.__context.CardFaces on TypeLine.id equals CardFaces.typeLine.id
                                        where CardFaces.id == cf.id
                                        select new Typeline {
         TypeName = Types.typeName
     }).ToList()
                                       where Print.Id == id
                                       select new CardResponse
     {
         Id = Print.Id,
         Name = cf.name,
         Loyalty = cf.loyalty,
         Toughness = cf.toughness,
         Power = cf.power,
         Price = Print.price,
         OracleText = cf.oracleText,
         FlavorText = pf.flavorText,
         Image = iu.large,
         Mana = mana,
         TypeLine = CardResponse.GetTypeLine(typeLine),
         Color = null
     }).FirstOrDefault());
 }
Ejemplo n.º 2
0
        public ActionResult <Response <DeckResponse> > GetDeckById(int deckId)
        {
            var deck = (from d in this.__context.Decks
                        join Commander in this.__context.Print on d.Commander equals Commander.Id
                        join Commanderpf in this.__context.PrintFace on Commander.Id equals Commanderpf.PrintId
                        join Commanderiu in this.__context.ImagesUrl on Commanderpf.id equals Commanderiu.printFace.id
                        join Commandercf in this.__context.CardFaces on Commander.Card.Id equals Commandercf.card.Id
                        let cards = (
                            from cd in this.__context.CardsDeck
                            join p in this.__context.Print on cd.print.Id equals p.Id
                            join PrintFace in this.__context.PrintFace on p.Id equals PrintFace.PrintId
                            join cf in this.__context.CardFaces on p.Card.Id equals cf.card.Id
                            join ImagesUrl in this.__context.ImagesUrl on PrintFace.id equals ImagesUrl.printFace.id
                            let tl = (from TypesInLine in this.__context.TypesInLine
                                      join Types in this.__context.Types on TypesInLine.type.id equals Types.id
                                      join TypeLine in this.__context.TypeLine on TypesInLine.line.id equals TypeLine.id
                                      join CardFaces in this.__context.CardFaces on TypeLine.id equals CardFaces.typeLine.id
                                      where CardFaces.id == cf.id
                                      select new Typeline {
                TypeName = Types.typeName
            }
                                      ).ToList()
                                     let mana = (from Costs in this.__context.Costs
                                                 from CostSymbols in this.__context.CostSymbols
                                                 join SymbolsInCosts in this.__context.SymbolsInCosts on Costs.id equals SymbolsInCosts.cost.id
                                                 where Costs.id == cf.manaCost.id && SymbolsInCosts.symbol.id == CostSymbols.id
                                                 select CostSymbols
                                                 ).ToList()
                                                let color = (from cic in this.__context.ColorsInCombinations
                                                             join c in this.__context.Color on cic.color.Id equals c.Id
                                                             where cic.combination.id == cf.color.id
                                                             select c.symbol
                                                             ).ToList()
                                                            where cd.deck.Id == d.Id
                                                            select new CardResponse()
            {
                Id = p.Id,
                FlavorText = PrintFace.flavorText,
                TypeLine = CardResponse.GetTypeLine(tl),
                Image = ImagesUrl.small,
                Loyalty = cf.loyalty,
                Mana = mana,
                Color = color,
                Name = cf.name,
                OracleText = cf.oracleText,
                Power = cf.power,
                Toughness = cf.toughness,
                Price = p.price
            }
                            ).ToList()
                                    where d.Id == deckId
                                    select new DeckResponseWithCards()
            {
                Name = d.Name,
                CommanderName = Commandercf.name,
                Id = d.Id,
                Image = Commanderiu.art_crop,
                FullImage = Commanderiu.normal,
                Cards = cards
            }
                        ).FirstOrDefault();

            return(Ok(new Response <DeckResponse>()
            {
                Data = deck,
                Success = true
            }));
        }