Example #1
0
        public async Task <IHttpActionResult> DeleteStation(int stationId)
        {
            string token  = Request.Headers.GetValues("Authorization").FirstOrDefault();
            int    userId = JwtHelper.Instance.GetUserId(token);

            IStationDao           stationDao = AdoFactory.Instance.GetStationDao("wetr");
            IEnumerable <Station> stations   = await stationDao.FindByUserIdAsync(userId);

            if (stations.Where(s => s.StationId == stationId).Count() == 0)
            {
                /* No station found so it might have been already deleted. */
                return(Content(HttpStatusCode.Forbidden, new object()));
            }

            IMeasurementDao measurementDao = AdoFactory.Instance.GetMeasurementDao("wetr");

            if ((await measurementDao.FindByStationIdAsync(stationId)).Count() > 0)
            {
                /* There must not be any measurmenets associated with this station. */
                return(Content(HttpStatusCode.Forbidden, new object()));
            }

            await stationDao.DeleteAsync(stationId);

            return(Content(HttpStatusCode.OK, new object()));
        }
        public static async Task ClassCleanupAsync()
        {
            foreach (var m in measurements)
            {
                await measurementDao.DeleteAsync(m.MeasurementId);
            }

            await unitDao.DeleteAsync(34);

            await measurementTypeDao.DeleteAsync(43);

            await stationDao.DeleteAsync(32);

            await stationTypeDao.DeleteAsync(83);

            await addressDao.DeleteAsync(93);

            await communityDao.DeleteAsync(74);

            await districtDao.DeleteAsync(54);

            await provinceDao.DeleteAsync(66);

            await countryDao.DeleteAsync(33);

            await userDao.DeleteAsync(23);
        }
Example #3
0
        public static async Task ClassCleanupAsync()
        {
            await stationDao.DeleteAsync(1);

            await stationTypeDao.DeleteAsync(1);

            await addressDao.DeleteAsync(6);

            await communityDao.DeleteAsync(6);

            await districtDao.DeleteAsync(6);

            await provinceDao.DeleteAsync(6);

            await countryDao.DeleteAsync(9);

            await userDao.DeleteAsync(1);
        }
Example #4
0
 public async Task <bool> DeleteStation(Station station)
 {
     try
     {
         return(await stationDao.DeleteAsync(station.StationId));
     }
     catch (Common.Dal.Ado.MySqlException ex)
     {
         throw new BusinessSqlException(ex.Message, ex.InnerException);
     }
 }