示例#1
0
        /// <summary>
        /// Gets all the <see cref="TModel"/> defined by the query parameters.
        /// </summary>
        /// <returns>A <see cref="Exceptional{List{Set}}"/> representing the result containing all the items.</returns>
        public override Exceptional <List <Set> > All()
        {
            try
            {
                var query       = BuildUri(_whereQueries);
                var rootSetList = CallWebServiceGet <RootSetListDto>(query).Result;

                return(Exceptional <List <Set> > .Success(MapSetsList(rootSetList), MtgApiController.CreatePagingInfo()));
            }
            catch (AggregateException ex)
            {
                return(Exceptional <List <Set> > .Failure(ex.Flatten().InnerException));
            }
        }
示例#2
0
        /// <summary>
        /// Find a specific set by its set code.
        /// </summary>
        /// <param name="code">The set code to query for.</param>
        /// <returns>A <see cref="Exceptional{Set}"/> representing the result containing a <see cref="Set"/> or an exception.</returns>
        public Exceptional <Set> Find(string code)
        {
            try
            {
                var rootSet = CallWebServiceGet <RootSetDto>(BuildUri(code)).Result;
                var model   = new Set(rootSet.Set);

                return(Exceptional <Set> .Success(model, MtgApiController.CreatePagingInfo()));
            }
            catch (AggregateException ex)
            {
                return(Exceptional <Set> .Failure(ex.Flatten().InnerException));
            }
        }
示例#3
0
        /// <summary>
        /// Gets all the <see cref="TModel"/> defined by the query parameters.
        /// </summary>
        /// <returns>A <see cref="Exceptional{List{Set}}"/> representing the result containing all the items.</returns>
        public async override Task <Exceptional <List <Set> > > AllAsync()
        {
            try
            {
                var query       = BuildUri(_whereQueries);
                var rootSetList = await CallWebServiceGet <RootSetListDto>(query).ConfigureAwait(false);

                return(Exceptional <List <Set> > .Success(MapSetsList(rootSetList), MtgApiController.CreatePagingInfo()));
            }
            catch (Exception ex)
            {
                return(Exceptional <List <Set> > .Failure(ex));
            }
        }
示例#4
0
        /// <summary>
        /// Gets a list of all the card types.
        /// </summary>
        /// <returns>A list of all the card types.</returns>
        public async Task <Exceptional <List <string> > > GetCardTypesAsync()
        {
            try
            {
                var url          = new Uri(new Uri(BaseMtgUrl), string.Concat(Version.GetDescription(), "/", ApiEndPoint.CardTypes.GetDescription()));
                var rootTypeList = await CallWebServiceGet <RootCardTypeDto>(url).ConfigureAwait(false);

                return(Exceptional <List <string> > .Success(rootTypeList.Types, MtgApiController.CreatePagingInfo()));
            }
            catch (Exception ex)
            {
                return(Exceptional <List <string> > .Failure(ex));
            }
        }
示例#5
0
        /// <summary>
        /// Gets a list of all the card types.
        /// </summary>
        /// <returns>A list of all the card types.</returns>
        public Exceptional <List <string> > GetCardTypes()
        {
            try
            {
                var url          = new Uri(new Uri(BaseMtgUrl), string.Concat(Version.GetDescription(), "/", ApiEndPoint.CardTypes.GetDescription()));
                var rootTypeList = CallWebServiceGet <RootCardTypeDto>(url).Result;

                return(Exceptional <List <string> > .Success(rootTypeList.Types, MtgApiController.CreatePagingInfo()));
            }
            catch (AggregateException ex)
            {
                return(Exceptional <List <string> > .Failure(ex.Flatten().InnerException));
            }
        }
示例#6
0
        /// <summary>
        /// Find a specific card by its multi verse identifier.
        /// </summary>
        /// <param name="id">The identifier to query for.</param>
        /// <returns>A <see cref="Exceptional{Card}"/> representing the result containing a <see cref="Card"/> or an exception.</returns>
        public Exceptional <Card> Find(string id)
        {
            try
            {
                var rootCard = CallWebServiceGet <RootCardDto>(BuildUri(id)).Result;
                var model    = new Card(rootCard.Card);

                return(Exceptional <Card> .Success(model, MtgApiController.CreatePagingInfo()));
            }
            catch (AggregateException ex)
            {
                return(Exceptional <Card> .Failure(ex.Flatten().InnerException));
            }
        }
示例#7
0
        /// <summary>
        /// Find a specific card by its set code.
        /// </summary>
        /// <param name="code">The set code to query for.</param>
        /// <returns>A <see cref="Exceptional{Set}"/> representing the result containing a <see cref="Set"/> or an exception.</returns>
        public async Task <Exceptional <Set> > FindAsync(string code)
        {
            try
            {
                var rootSet = await CallWebServiceGet <RootSetDto>(BuildUri(code)).ConfigureAwait(false);

                var model = new Set(rootSet.Set);

                return(Exceptional <Set> .Success(model, MtgApiController.CreatePagingInfo()));
            }
            catch (Exception ex)
            {
                return(Exceptional <Set> .Failure(ex));
            }
        }
示例#8
0
        /// <summary>
        /// Find a specific card by its multi verse identifier.
        /// </summary>
        /// <param name="id">The identifier to query for.</param>
        /// <returns>A <see cref="Exceptional{Card}"/> representing the result containing a <see cref="Card"/> or an exception.</returns>
        public async Task <Exceptional <Card> > FindAsync(string id)
        {
            try
            {
                var rootCard = await CallWebServiceGet <RootCardDto>(BuildUri(id)).ConfigureAwait(false);

                var model = new Card(rootCard.Card);

                return(Exceptional <Card> .Success(model, MtgApiController.CreatePagingInfo()));
            }
            catch (Exception ex)
            {
                return(Exceptional <Card> .Failure(ex));
            }
        }
示例#9
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));
            }
        }
示例#10
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));
            }
        }