Example #1
0
        /**
         * This method builds the url for the request to East India Trading
         * with the parameters since they do not have a body for the request
         */
        private static string BuildUrl(CityEnum cityFrom, CityEnum cityTo, int weight, bool fragile, bool recorded)
        {
            string url = Config.EAST_INDIA_TRADING_URL +
                         "cityFrom=" + cityFrom.ToString() + "&" +
                         "cityTo=" + cityTo.ToString() + "&" +
                         "date=" + "date=" + System.DateTime.Now.Year + "-0" + System.DateTime.Now.Month + "-" + System.DateTime.Now.Day + "&" +
                         "shipmentType=STANDARD&" +
                         "weight=" + weight + "&" +
                         "isFragile=" + fragile + "&" +
                         "isRecorded=" + recorded;

            url = url.Replace("False", "false").Replace("True", "true");
            return(url);
        }
Example #2
0
        /**
         * This method builds the url for the request to Oceanic Airlines
         * with the parameters since they do not have a body for the request
         */
        private static string BuildUrl(CompanyEnum companyCode, CityEnum cityFrom, CityEnum cityTo, string parcelTyoe, int weight, int height, int width, int length)
        {
            string url = Config.OCEANIC_AIRLINES_URL;

            url += "companyCode=" + companyCode.ToString() + "&";
            url += "cityFrom=" + cityFrom.ToString() + "&";
            url += "&cityTo=" + cityTo.ToString() + "&";
            url += "parceltype=" + parcelTyoe + "&";
            url += "weight=" + weight + "&";
            url += "height=" + height + "&";
            url += "width=" + width + "&";
            url += "lenght=" + length;

            return(url);
        }
        public async Task <IActionResult> GetStationsWithinMetres(CityEnum city, int id, int metres = 0)
        {
            List <BikeStation> stations = (List <BikeStation>)cache.CheckCache(mySettingsOptions.DefaultCity);

            if (stations == null)
            {
                string result = await dbhelper.GetAllStations(city.ToString());

                stations = JsonConvert.DeserializeObject <List <BikeStation> >(result).ToList();
                cache.AddToCache(city.ToString(), stations);
            }
            metres = metres > 0 ? metres : mySettingsOptions.DefaultSearchRadius;

            var mystation      = stations.SingleOrDefault(x => x.stationNumber == id);
            var nearbyStations = GPSHelper.FindNearbyStations(stations, mystation, metres);

            return(Ok(nearbyStations));
        }
Example #4
0
        public static EastIndiaResponse RequestRoute(CityEnum cityTo, CityEnum cityFrom, int weight, bool fragile, bool recorded)
        {
            try {
                string url      = BuildUrl(cityTo, cityFrom, weight, fragile, recorded);
                string response = CommunicationController.Send(url, "");
                //Console.WriteLine(response);

                EastIndiaResponse eastIndiaResponse = JsonSerializer.Deserialize <EastIndiaResponse>(response);

                if (eastIndiaResponse.price == -1 || eastIndiaResponse.time == -1)
                {
                    return(null);
                }

                return(eastIndiaResponse);
            }
            catch (Exception) {
                return(null);
            }
        }
Example #5
0
        public static OceanicResponse RequestRoute(CompanyEnum companyCode, CityEnum cityFrom, CityEnum cityTo, string parcelTyoe, int weight, int height, int width, int length)
        {
            try {
                string url      = BuildUrl(companyCode, cityFrom, cityTo, parcelTyoe, weight, height, width, length);
                string response = CommunicationController.Send(url, "");
                //Console.WriteLine(response);

                OceanicResponse oceanicResponse = JsonSerializer.Deserialize <OceanicResponse>(response);

                if (oceanicResponse.price == -1 || oceanicResponse.time == -1)
                {
                    return(null);
                }

                return(oceanicResponse);
            }
            catch (Exception) {
                return(null);
            }
        }
        public async Task <IActionResult> GetStationById(CityEnum city, int id = 11)
        {
            List <BikeStation> stations = (List <BikeStation>)cache.CheckCache(city.ToString());
            BikeStation        station  = null;

            if (stations != null)
            {
                station = stations.Single(x => x.stationNumber == id);
            }
            else
            {
                string result = await dbhelper.GetStation(city.ToString(), id);

                station = JsonConvert.DeserializeObject <BikeStation>(result);
            }
            List <BikeStation> stationAsList = new List <BikeStation>()
            {
                station
            };

            return(Ok(stationAsList));
        }
 public async Task <IActionResult> SelectCity(CityEnum city)
 {
     return(Ok(city));      // inputs as string val (due to SwaggerConfig option); returns as corresponding number
 }
Example #8
0
 public static async Task <WeatherData> GetWeatherData(CityEnum city)
 {
     return(await GetWeatherData((int)city));
 }
Example #9
0
 public static City GetCityFromEnum(CityEnum cityEnum)
 {
     return(GetCityFromID((int)cityEnum));
 }
        /**
         * Check that the cities are directly connected. Returns null if
         * the cities are directly connected
         *
         * Insanely "good" and "short" method
         */
        public static string IsCitiesDirect(CityEnum cityFrom, CityEnum cityTo)
        {
            if (checkCites(cityFrom, cityTo, CityEnum.TANGER))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.MARRAKESH))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.TUNIS))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.SAHARA))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.TUNIS))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.TRIPOLI))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.TRIPOLI))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.OMDURMAN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.OMDURMAN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.CAIRO))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.DARFUR))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.SUAKIN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.DARFUR))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.ADDIS_ABEBA))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.ADDIS_ABEBA))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.KAP_GUARDAFUI))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.VICTORIASOEEN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.KAP_GUARDAFUI))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.ZANZIBAR))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.ZANZIBAR))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.MOCAMBIQUE))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.VICTORIASOEEN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.MOCAMBIQUE))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.DRAGEBJERGET))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.VICTORIA_FALDENE))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.LUANDA))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.DRAGEBJERGET))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.VICTORIA_FALDENE))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.VICTORIA_FALDENE))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.HVALBUGTEN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.HVALBUGTEN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.KAPSTADEN))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.LUANDA))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.LUANDA))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.CONGO))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.KABALO))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.CONGO))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.SLAVEKYSTEN))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.WADAI))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.DARFUR))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.SLAVEKYSTEN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.TIMBUKTU))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.WADAI))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.DARFUR))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.TIMBUKTU))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.GULDKYSTEN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.GULDKYSTEN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.SIERRA_LEONE))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.TIMBUKTU))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.DAKAR))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.MARRAKESH))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.MARRAKESH))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.SAHARA))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.SAHARA))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.DAKAR))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.DARFUR))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.WADAI))
                {
                    return(null);
                }

                if (checkCites(cityFrom, cityTo, CityEnum.BAHR_EL_GHAZAL))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.BAHR_EL_GHAZAL))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.VICTORIASOEEN))
                {
                    return(null);
                }
            }

            if (checkCites(cityFrom, cityTo, CityEnum.VICTORIASOEEN))
            {
                if (checkCites(cityFrom, cityTo, CityEnum.KABALO))
                {
                    return(null);
                }
            }

            return("City is not direct");
        }
 private static bool checkCites(CityEnum c1, CityEnum c2, CityEnum c3)
 {
     return(c1 == c3 || c2 == c3);
 }
 /**
  * Check that the cities are directly connected
  */
 public static string isCitiesDirect(CityEnum cityFrom, CityEnum cityTo)
 {
     //TODO implement (direct routes will be in database)
     return(null);
 }