Example #1
0
        public void TestCardSearch()
        {
            List <mtgCard.Card> listOfResults = new List <mtgCard.Card>();

            mtgService.CardService apiService = new mtgService.CardService();
            var result = apiService.Where(x => x.Name, "Lightning Bolt")
                         //.Where(x => x.Set, "c17")
                         .All();

            /*            foreach (var card in result.Value)
             *          {
             *              var printings = card.Printings;
             *              foreach (var set in printings)
             *              {
             *                  Console.WriteLine(set);
             *              }
             *
             *          }*/

            if (result.Value.Count != 0)
            {
                foreach (var printing in result.Value[0].Printings)
                {
                    Console.WriteLine(printing);
                }
            }
            //Console.ReadLine();
        }
Example #2
0
        public void FindCardWithApi(Card card)
        {
            List <mtgCard.Card> listOfResults = new List <mtgCard.Card>();

            mtgService.CardService apiService = new mtgService.CardService();

            var searchResults = apiService.Where(x => x.Name, card.Name)
                                .All();

            if (searchResults.Value.Count != 0)
            {
                var sets = searchResults.Value[0].Printings;
            }
        }
Example #3
0
        /// <summary>
        ///  Generates a booster pack for a specific set asynchronously.
        /// </summary>
        /// <param name="code">The set code to generate a booster for.</param>
        /// <returns>A <see cref="Exceptional{List{Card}}"/> representing the result containing a <see cref="List{Card}"/> or an exception.</returns>
        public async Task <Exceptional <List <Card> > > GenerateBoosterAsync(string code)
        {
            try
            {
                var url          = new Uri(Path.Combine(BuildUri(code).AbsoluteUri, "booster"));
                var rootCardList = await CallWebServiceGet <RootCardListDto>(url).ConfigureAwait(false);

                return(Exceptional <List <Card> > .Success(CardService.MapCardsList(rootCardList), MtgApiController.CreatePagingInfo()));
            }
            catch (Exception ex)
            {
                return(Exceptional <List <Card> > .Failure(ex));
            }
        }
Example #4
0
        /// <summary>
        ///  Generates a booster pack for a specific set.
        /// </summary>
        /// <param name="code">The set code to generate a booster for.</param>
        /// <returns>A <see cref="Exceptional{List{Card}}"/> representing the result containing a <see cref="List{Card}"/> or an exception.</returns>
        public Exceptional <List <Card> > GenerateBooster(string code)
        {
            try
            {
                var url          = new Uri(Path.Combine(BuildUri(code).AbsoluteUri, "booster"), UriKind.Absolute);
                var rootCardList = CallWebServiceGet <RootCardListDto>(url).Result;

                return(Exceptional <List <Card> > .Success(CardService.MapCardsList(rootCardList), MtgApiController.CreatePagingInfo()));
            }
            catch (AggregateException ex)
            {
                return(Exceptional <List <Card> > .Failure(ex.Flatten().InnerException));
            }
        }