コード例 #1
0
 public void Can_GetStations()
 {
     IGasStationRepository repos = new MapQuestRepository();
     List<IStation> stations = repos.GetStations("28.54644912706383", "-81.46342522071842");
     Assert.IsNotNull(stations);
     Assert.IsTrue(stations.Count > 0);
 }
コード例 #2
0
 public void Can_GetStationsByZip()
 {
     IGasStationRepository repos = new MapQuestRepository();
     ((MapQuestRepository)repos).Db = new SqlDatabase(_TEST_CONN_STR);
     List<IStation> stations = repos.GetStations("90275");
     Assert.IsNotNull(stations);
     Assert.IsTrue(stations.Count > 0);
 }
コード例 #3
0
 public JsonResult GetStations(string latitude, string longitude, string type, string zip)
 {
     List<IStation> stations = null;
     IGasStationRepository repos;
     switch (type)
     {
         case "mapquest":
             repos = new MapQuestRepository();
             if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
             {
                 stations = repos.GetStations(latitude, longitude);
                 break;
             }
             if (!string.IsNullOrEmpty(zip))
             {
                 ((MapQuestRepository)repos).Db = new SqlDatabase(_DB_CONN_STR);
                 stations = repos.GetStations(zip);
                 break;
             }
             break;
         case "gaspricewatch":
             repos = new GasPriceWatchRepository();
             if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
             {
                 stations = repos.GetStations(latitude, longitude);
                 break;
             }
             if (!string.IsNullOrEmpty(zip))
             {
                 ((GasPriceWatchRepository)repos).Db = new SqlDatabase(_DB_CONN_STR);
                 stations = repos.GetStations(zip);
                 break;
             }
             break;
         case "gasbuddy":
             repos = new GasBuddyRepository();
             if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
             {
                 stations = repos.GetStations(latitude, longitude);
                 break;
             }
             if (!string.IsNullOrEmpty(zip))
             {
                 ((GasBuddyRepository)repos).Db = new SqlDatabase(_DB_CONN_STR);
                 stations = repos.GetStations(zip);
                 break;
             }
             break;
         case "msn":
             repos = new MSNAutosRepository(Server.MapPath("../tessdata"));
             if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
             {
                 stations = repos.GetStations(latitude, longitude);
                 break;
             }
             if (!string.IsNullOrEmpty(zip))
             {
                 ((MSNAutosRepository)repos).Db = new SqlDatabase(_DB_CONN_STR);
                 stations = repos.GetStations(zip);
                 break;
             }
             break;
             break;
     }
     return Json(stations);
 }