Ejemplo n.º 1
0
        private IEnumerable <CardViewModel> GetGameCards(SharpEntityResults <Starship> sharpEntityResults)
        {
            var allStarShips = sharpEntityResults.results
                               .Select(cdvm => cdvm);
            var allCardViewModels = mCardMapper.MapEntityToViewModel_List(allStarShips);

            return(allCardViewModels);
        }
Ejemplo n.º 2
0
        private async Task <SharpEntityResults <T> > GetAllPaginated <T>(string entityName, string pageNumber = "1") where T : SharpEntity
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("page", pageNumber);

            SharpEntityResults <T> result = await GetMultiple <T>(entityName, parameters);

            result.nextPageNo     = String.IsNullOrEmpty(result.next) ? null : GetQueryParameters(result.next)["page"];
            result.previousPageNo = String.IsNullOrEmpty(result.previous) ? null : GetQueryParameters(result.previous)["page"];

            return(result);
        }
Ejemplo n.º 3
0
        private SharpEntityResults <T> GetMultiple <T>(string endpoint, Dictionary <string, string> parameters) where T : SharpEntity
        {
            string serializedParameters = "";

            if (parameters != null)
            {
                serializedParameters = "?" + SerializeDictionary(parameters);
            }

            string json = Request(string.Format("{0}{1}{2}", apiUrl, endpoint, serializedParameters), HttpMethod.GET);
            SharpEntityResults <T> swapiResponse = JsonConvert.DeserializeObject <SharpEntityResults <T> >(json);

            return(swapiResponse);
        }
Ejemplo n.º 4
0
        private async Task <SharpEntityResults <T> > GetMultiple <T>(string endpoint, Dictionary <string, string> parameters) where T : SharpEntity
        {
            string serializedParameters = "";

            if (parameters != null)
            {
                serializedParameters = "?" + SerializeDictionary(parameters);
            }

            string json = await Request($"{apiUrl}{endpoint}{serializedParameters}", HttpMethod.GET);

            SharpEntityResults <T> swapiResponse = JsonConvert.DeserializeObject <SharpEntityResults <T> >(json);

            return(swapiResponse);
        }
Ejemplo n.º 5
0
        public List <Starship> GetAllStarships(string pageNumber = "1")
        {
            string nextPage = pageNumber;
            //int currentPage = 0;
            List <Starship> resultList = new List <Starship>();

            while (!String.IsNullOrWhiteSpace(nextPage))//Make multiple calls until next page is null.
            {
                SharpTrooperCore sharpTrooperClient  = new SharpTrooperCore();
                SharpEntityResults <Starship> result = sharpTrooperClient.GetAllStarships(nextPage);

                //Add results to Returning List
                resultList.AddRange(result.results);

                nextPage = result.nextPageNo;
            }

            return(resultList);
        }
        public IQueryable <Person> GetPeople(string search)
        {
            var sharpTrooperCore = new SharpTrooper.Core.SharpTrooperCore();

            var results = new List <People>();

            SharpEntityResults <People> peopleResults = null;
            var nextPageNo = "";

            while (peopleResults == null || peopleResults.next != null)
            {
                peopleResults = sharpTrooperCore.GetAllPeople(nextPageNo, search);
                nextPageNo    = peopleResults.nextPageNo;
                results.AddRange(peopleResults.results);
            }

            return(results
                   .Select(element => Mapper.Map <Person>(element))
                   .AsQueryable <Person>());
        }
        private SharpEntityResults <T> GetAllPaginated <T>(string entityName, string pageNumber = null, string search = null) where T : SharpEntity
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(pageNumber))
            {
                parameters.Add("page", pageNumber);
            }

            if (!string.IsNullOrEmpty(search))
            {
                parameters.Add("search", search);
            }

            SharpEntityResults <T> result = GetMultiple <T>(entityName, parameters);

            result.nextPageNo     = String.IsNullOrEmpty(result.next) ? null : GetQueryParameters(result.next)["page"];
            result.previousPageNo = String.IsNullOrEmpty(result.previous) ? null : GetQueryParameters(result.previous)["page"];

            return(result);
        }
Ejemplo n.º 8
0
        private SharpEntityResults <T> GetAllPaginated <T>(string entityName, string pageNumber = "1") where T : SharpEntity
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("page", pageNumber);

            SharpEntityResults <T> result = GetMultiple <T>(entityName, parameters);

            result.nextPageNo     = String.IsNullOrEmpty(result.next) ? null : GetQueryParameters(result.next)["page"];
            result.previousPageNo = String.IsNullOrEmpty(result.previous) ? null : GetQueryParameters(result.previous)["page"];

            while (!String.IsNullOrEmpty(result.nextPageNo))
            {
                parameters["page"] = result.nextPageNo;
                SharpEntityResults <T> tempResult = GetMultiple <T>(entityName, parameters);
                result.results.AddRange(tempResult.results);
                result.nextPageNo = String.IsNullOrEmpty(tempResult.next) ? null : GetQueryParameters(tempResult.next)["page"];
            }

            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// get all the people resources
        /// </summary>
        public async Task <SharpEntityResults <People> > GetAllPeople(string pageNumber = "1")
        {
            SharpEntityResults <People> result = await GetAllPaginated <People>("/people/", pageNumber);

            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// get all the film resources
        /// </summary>
        public SharpEntityResults <Film> GetAllFilms(string pageNumber = "1")
        {
            SharpEntityResults <Film> result = GetAllPaginated <Film>("/films/", pageNumber);

            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// get all the people resources
        /// </summary>
        public SharpEntityResults <People> GetAllPeople(string pageNumber = "1")
        {
            SharpEntityResults <People> result = GetAllPaginated <People>("/people/", pageNumber);

            return(result);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// get all the vehicle resources
        /// </summary>
        public async Task <SharpEntityResults <Vehicle> > GetAllVehicles(string pageNumber = "1")
        {
            SharpEntityResults <Vehicle> result = await GetAllPaginated <Vehicle>("/vehicles/", pageNumber);

            return(result);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// get all the planet resources
        /// </summary>
        public SharpEntityResults <Planet> GetAllPlanets(string pageNumber = "1")
        {
            SharpEntityResults <Planet> result = GetAllPaginated <Planet>("/planets/", pageNumber);

            return(result);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// get all the specie resources
        /// </summary>
        public async Task <SharpEntityResults <Specie> > GetAllSpecies(string pageNumber = "1")
        {
            SharpEntityResults <Specie> result = await GetAllPaginated <Specie>("/species/", pageNumber);

            return(result);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// get all the starship resources
        /// </summary>
        public async Task <SharpEntityResults <Starship> > GetAllStarships(string pageNumber = "1")
        {
            SharpEntityResults <Starship> result = await GetAllPaginated <Starship>("/starships/", pageNumber);

            return(result);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// get all the film resources
        /// </summary>
        public async Task <SharpEntityResults <Film> > GetAllFilms(string pageNumber = "1")
        {
            SharpEntityResults <Film> result = await GetAllPaginated <Film>("/films/", pageNumber);

            return(result);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// get all the planet resources
        /// </summary>
        public async Task <SharpEntityResults <Planet> > GetAllPlanets(string pageNumber = "1")
        {
            SharpEntityResults <Planet> result = await GetAllPaginated <Planet>("/planets/", pageNumber);

            return(result);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// get all the specie resources
        /// </summary>
        public SharpEntityResults <Specie> GetAllSpecies(string pageNumber = "1")
        {
            SharpEntityResults <Specie> result = GetAllPaginated <Specie>("/species/", pageNumber);

            return(result);
        }
        /// <summary>
        /// get all the people resources
        /// </summary>
        public SharpEntityResults <People> GetAllPeople(string pageNumber = null, string search = null)
        {
            SharpEntityResults <People> result = GetAllPaginated <People>("/people/", pageNumber, search);

            return(result);
        }
Ejemplo n.º 20
0
        //IRepository<Person> personRepo = new Repository<Person>();

        public PersonRespository()
        {
            _personList = core.GetAllPeople();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// get all the vehicle resources
        /// </summary>
        public SharpEntityResults <Vehicle> GetAllVehicles(string pageNumber = "1")
        {
            SharpEntityResults <Vehicle> result = GetAllPaginated <Vehicle>("/vehicles/", pageNumber);

            return(result);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// get all the starship resources
        /// </summary>
        public SharpEntityResults <Starship> GetAllStarships(string pageNumber = "1")
        {
            SharpEntityResults <Starship> result = GetAllPaginated <Starship>("/starships/", pageNumber);

            return(result);
        }