Exemplo n.º 1
0
        public async Task <bool> AddMeasurement(Measurement m)
        {
            /* Process for weather warning */

            await CheckForWarning(m);

            return(await measurementDao.InsertAsync(m));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PostMeasurement(MeasurementDTO measurement)
        {
            /* Check if model is valid */
            if (!ModelState.IsValid)
            {
                var errors = ModelState.ToDictionary(
                    kvp => kvp.Key,
                    kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
                    );
                return(Content(HttpStatusCode.BadRequest, errors));
            }

            IMeasurementDao dao = AdoFactory.Instance.GetMeasurementDao("wetr");
            await dao.InsertAsync(measurement.ToMeasurement());

            return(Content(HttpStatusCode.OK, new object()));
        }
Exemplo n.º 3
0
        public static async Task ClassInitializeAsync(TestContext context)
        {
            User user = new User()
            {
                UserId    = 23,
                FirstName = "Daniel",
                LastName  = "Englisch",
                Email     = "*****@*****.**",
                Password  = "******"
            };

            await userDao.InsertAsync(user);

            Country country = new Country
            {
                CountryId = 33,
                Name      = "MyCountry"
            };

            await countryDao.InsertAsync(country);

            Province province = new Province
            {
                ProvinceId = 66,
                CountryId  = country.CountryId,
                Name       = "MyProvince"
            };

            await provinceDao.InsertAsync(province);

            District district = new District
            {
                DistrictId = 54,
                ProvinceId = province.ProvinceId,
                Name       = "MyDistrict"
            };

            await districtDao.InsertAsync(district);

            Community community = new Community
            {
                CommunityId = 74,
                DistrictId  = district.DistrictId,
                Name        = "MyCommunity"
            };

            await communityDao.InsertAsync(community);

            Address address = new Address
            {
                AddressId   = 93,
                CommunityId = community.CommunityId,
                Location    = "Waidhofnerstraße 34a",
                Zip         = "332A"
            };

            await addressDao.InsertAsync(address);

            StationType stationType = new StationType
            {
                StationTypeId = 83,
                Name          = "DeluxeStation"
            };

            await stationTypeDao.InsertAsync(stationType);

            Station station = new Station
            {
                StationId     = 32,
                UserId        = user.UserId,
                AddressId     = address.AddressId,
                Name          = "TemperaturStation",
                Latitude      = 3.323M,
                Longitude     = -3.333M,
                StationTypeId = stationType.StationTypeId
            };

            await stationDao.InsertAsync(station);

            MeasurementType measurementType = new MeasurementType
            {
                MeasurementTypeId = 43,
                Name = "Temperatur"
            };

            await measurementTypeDao.InsertAsync(measurementType);

            Unit unit = new Unit
            {
                UnitId = 34,
                Name   = "Celcius"
            };

            await unitDao.InsertAsync(unit);

            Measurement m1 = new Measurement
            {
                MeasurementId     = 44,
                MeasurementTypeId = measurementType.MeasurementTypeId,
                StationId         = station.StationId,
                Value             = 23.3,
                TimesStamp        = DateTime.FromFileTime(131862006360000000),
                UnitId            = unit.UnitId
            };

            Measurement m2 = new Measurement
            {
                MeasurementId     = 45,
                MeasurementTypeId = measurementType.MeasurementTypeId,
                StationId         = station.StationId,
                Value             = -0.3,
                TimesStamp        = DateTime.Now,
                UnitId            = unit.UnitId
            };

            Measurement m3 = new Measurement
            {
                MeasurementId     = 46,
                MeasurementTypeId = measurementType.MeasurementTypeId,
                StationId         = station.StationId,
                Value             = 12.85,
                TimesStamp        = DateTime.Now,
                UnitId            = unit.UnitId
            };

            measurements.Add(m1);
            measurements.Add(m2);
            measurements.Add(m3);

            foreach (var m in measurements)
            {
                await measurementDao.InsertAsync(m);
            }
        }