Beispiel #1
0
        public void RegisterParkEntery(ParkingDTO zoneReg)
        {
            var parkingData = new ZoneParkingData
            {
                Vehicle = _datagetter.QueryVehicle(zoneReg.RfidCar),
                Sensor  = _datagetter.QuerySensor(zoneReg.Sensor),
                Date    = DateTime.Now
            };

            _parkingReg.registerParkEntery(parkingData);
        }
Beispiel #2
0
 public void InsertRegisterZoneParking(ZoneParkingData zoneParking)
 {
     try
     {
         using var context = new SmartCityZoneContext();
         context.Add(zoneParking);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine("Problem connecting to DB when registering ar ZoneParking");
         throw e;
     }
 }
        public void registerParkEntery(ZoneParkingData parkingData)
        {
            try
            {
                using var context = new SmartCityZoneContext();

                parkingData.Vehicle = context.Vehicles
                                      .Where(x => x.VehicleId == parkingData.Vehicle.VehicleId)
                                      .First();
                parkingData.Sensor = context.Sensors
                                     .Where(x => x.SensorId == parkingData.Sensor.SensorId)
                                     .First();

                context.Add(parkingData);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem connecting to DB when registering a Atmosphere reading");
                throw e;
            }
        }