Esempio n. 1
0
        //Get starship detailsl

        public static SwStarship GetSwStarshipById(int id)
        {
            IRepository <Starship> starshipRepo = new Repository <Starship>();
            Starship starship = starshipRepo.GetById(id);



            SwStarship swStarship = SwApiMapping.MapStarship(starship);

            if (swStarship.CostInCredits > 2147483647)
            {
                swStarship.CostInCredits = 2147483647.0M;
            }

            Dictionary <int, string> starshipImageURLs = new Dictionary <int, string>();

            starshipImageURLs.Add(100, "https://www.vhv.rs/file/max/27/271590_millennium-falcon-png.png");

            if (starshipImageURLs.ContainsKey(id))
            {
                swStarship.ImageURL = starshipImageURLs[id];
            }
            else
            {
                swStarship.ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Emblem_of_the_First_Galactic_Empire.svg/600px-Emblem_of_the_First_Galactic_Empire.svg.png";
            }

            return(swStarship);
        }
Esempio n. 2
0
        //Get all starships
        public static List <SwStarship> GetSwStarships()
        {
            //Hit API, get collection of starships in ambigous collection (var)

            IRepository <Starship> starshipRepo = new Repository <Starship>();
            var starships = starshipRepo.GetEntities(1, 40);
            List <SwStarship> swStarships = new List <SwStarship>();

            foreach (Starship starship in starships)
            {
                SwStarship swStarship = SwApiMapping.MapStarship(starship);
                // if (swStarship.CostInCredits > 2147483647) swStarship.CostInCredits = 2147483647.0M;
                if (swStarship.CostInCredits > 20000)
                {
                    swStarships.Add(swStarship);
                }
            }

            return(swStarships);
        }