Ejemplo n.º 1
0
        /// <inheritdoc />
        async Task <IDictionaryRange <int, Continent> > IRepository <int, Continent> .FindAllAsync(CancellationToken cancellationToken)
        {
            IContinentRepository self = this;
            var request = new ContinentRequest
            {
                Culture = self.Culture
            };
            var response = await this.serviceClient.SendAsync <ContinentCollectionDTO>(request, cancellationToken).ConfigureAwait(false);

            if (response.Content == null || response.Content.Continents == null)
            {
                return(new DictionaryRange <int, Continent>(0));
            }

            var values     = this.continentCollectionConverter.Convert(response.Content, null);
            var continents = new DictionaryRange <int, Continent>(values.Count)
            {
                SubtotalCount = values.Count,
                TotalCount    = values.Count
            };

            foreach (var continent in values)
            {
                continent.Culture = request.Culture;
                continents.Add(continent.ContinentId, continent);
            }

            return(continents);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        IDictionaryRange <int, Continent> IRepository <int, Continent> .FindAll()
        {
            IContinentRepository self = this;
            var request = new ContinentRequest
            {
                Culture = self.Culture
            };
            var response = this.serviceClient.Send <ContinentCollectionDTO>(request);

            if (response.Content == null || response.Content.Continents == null)
            {
                return(new DictionaryRange <int, Continent>(0));
            }

            var values     = this.continentCollectionConverter.Convert(response.Content, null);
            var continents = new DictionaryRange <int, Continent>(values.Count)
            {
                SubtotalCount = values.Count,
                TotalCount    = values.Count
            };

            foreach (var continent in values)
            {
                continent.Culture = request.Culture;
                continents.Add(continent.ContinentId, continent);
            }

            return(continents);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        Task <IDictionaryRange <int, Continent> > IRepository <int, Continent> .FindAllAsync(CancellationToken cancellationToken)
        {
            IContinentRepository self = this;
            var request = new ContinentRequest
            {
                Culture = self.Culture
            };

            return(this.serviceClient.SendAsync <ContinentCollectionDataContract>(request, cancellationToken).ContinueWith <IDictionaryRange <int, Continent> >(
                       task =>
            {
                var response = task.Result;
                if (response.Content == null || response.Content.Continents == null)
                {
                    return new DictionaryRange <int, Continent>(0);
                }

                var values = this.converterForContinentCollection.Convert(response.Content, null);
                var continents = new DictionaryRange <int, Continent>(values.Count)
                {
                    SubtotalCount = values.Count,
                    TotalCount = values.Count
                };

                foreach (var continent in values)
                {
                    continent.Culture = request.Culture;
                    continents.Add(continent.ContinentId, continent);
                }

                return continents;
            },
                       cancellationToken));
        }