public async Task <IEnumerable <Station> > GetAllStations() { try { IStationDao stationDao = GetIStationDao(); return(await stationDao.FindAllAsync()); } catch (Exception) { return(null); } }
public async Task <IEnumerable <Station> > GetAllStations() { try { return(await stationDao.FindAllAsync()); } catch (Common.Dal.Ado.MySqlException ex) { throw new BusinessSqlException(ex.Message, ex.InnerException); } }
public async Task <IEnumerable <Station> > FilterByRegion(GeoCoordinate geoCoordinate, double radius = 0) { try { IStationDao stationDao = GetIStationDao(); IEnumerable <Station> stations = await stationDao.FindAllAsync(); List <Station> returnStations = new List <Station>(); foreach (Station station in stations) { if (DistanceTo(geoCoordinate.Latitude, geoCoordinate.Longitude, station.Latitude, station.Longitude) <= radius) { returnStations.Add(station); } } return(returnStations); } catch (Exception) { return(null); } }
public async override Task TestFindAllAsync() { using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { Station station = new Station { StationId = 3, Name = "Station 1", Longitude = 12, Latitude = 12, StationTypeId = 1, AddressId = 6, UserId = 1 }; Station station2 = new Station { StationId = 4, Name = "Station 2", Longitude = 12, Latitude = 12, StationTypeId = 1, AddressId = 6, UserId = 1 }; await stationDao.InsertAsync(station); await stationDao.InsertAsync(station2); IEnumerable <Station> stations = await stationDao.FindAllAsync(); CollectionAssert.Contains(stations.ToList(), station); CollectionAssert.Contains(stations.ToList(), station2); // Never called since a rollback of the db is desired // transaction.Complete(); } }
public async Task <IHttpActionResult> GetStations(int communityId) { IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); ICommunityDao communitDao = AdoFactory.Instance.GetCommunityDao("wetr"); IDistrictDao districtDao = AdoFactory.Instance.GetDistrictDao("wetr"); IProvinceDao provinceDao = AdoFactory.Instance.GetProvinceDao("wetr"); ICountryDao countryDao = AdoFactory.Instance.GetCountryDao("wetr"); IEnumerable <Station> stations = null; stations = await stationDao.FindAllAsync(); List <StationDTO> convertedStations = new List <StationDTO>(); /* Infer location ids for convenience */ foreach (var s in stations) { StationDTO station = new StationDTO(s); station.CommunityId = (await addressDao.FindByIdAsync(station.AddressId)).CommunityId; station.DistrictId = (await communitDao.FindByIdAsync(station.CommunityId)).DistrictId; station.ProvinceId = (await districtDao.FindByIdAsync(station.DistrictId)).ProvinceId; station.CountryId = (await provinceDao.FindByIdAsync(station.ProvinceId)).CountryId; station.Location = (await addressDao.FindByIdAsync(station.AddressId)).Location; convertedStations.Add(station); } if (communityId != 0) { convertedStations.RemoveAll(s => s.CommunityId != communityId); } return(Content(HttpStatusCode.OK, convertedStations)); }