Пример #1
0
 public void Update(VehicleLog vehicleLog)
 {
     if (vehicleLog.OutTime.HasValue)
     {
         vehicleLog.AmountReceived = _parkingChargesCalculator.Calculate(vehicleLog.InTime,
                                                                         Convert.ToDateTime(vehicleLog.OutTime), vehicleLog.ParkingLotName, vehicleLog.VehicleType);
     }
     _vehicleLogRepository.Update(vehicleLog);
 }
 public void Update(VehicleLog vehicleLog)
 {
     using (var conn = new SQLiteConnection(_config.GetConnectionString()))
     {
         conn.Open();
         conn.Execute(@"UPDATE t_vehicle_log SET lot_id=@lot_id, vehicle_type_id=@vehicle_type_id, vehicle_no=@vehicle_no, in_time=@in_time, out_time=@out_time,amount=@amount, weight=@weight)
              WHERE id = @id",
                      vehicleLog);
     }
 }
 public void Save(VehicleLog vehicleLog)
 {
     using (var conn = new SQLiteConnection(_config.GetConnectionString()))
     {
         conn.Open();
         conn.Execute(@"INSERT INTO t_vehicle_log (lot_id, vehicle_type_id, vehicle_no, in_time, out_time,amount, weight)
              VALUES (@lot_id, @vehicle_type_id, @vehicle_no, @in_time, @out_time,@amount, @weight)",
                      vehicleLog);
     }
 }
Пример #4
0
        public JsonResult AddVehicleLog(int vehicleId, DateTime time, bool isEntry, string tagNumber)
        {
            var log = new VehicleLog
            {
                TagNumber = tagNumber,
                Time      = time,
                VehicleId = vehicleId,
                IsEntry   = isEntry
            };

            db.VehicleLogs.Add(log);
            db.SaveChanges();
            return(Json("", JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public async Task <bool> UpdateVehicleStatus(int id, bool IsResponse)
        {
            if (!Any(id))
            {
                return(false);
            }


            var _Vehicle = await Get(id, a => a.LastVehicleLog);

            //Check Valid Response From The Vehicle Ping Request  ...
            //IsResponse = RequestPingVehicle(_Vehicle.Id);

            //Get Last Status ...


            // New Status For Vehicle if no logs or Different Status ...
            if (_Vehicle.LastVehicleLogId == null || _Vehicle.LastVehicleLog.IsResponse != IsResponse)
            {
                var _NewStatus = new VehicleLog()
                {
                    IsResponse  = IsResponse,
                    UpdatedTime = DateTime.Now,
                    VehicleId   = _Vehicle.Id,
                };
                await _vehicleLogService.Add(_NewStatus);

                //Ref to last Id
                _Vehicle.LastVehicleLogId = _NewStatus.Id;
                return(await Update(_Vehicle));
            }
            else // Update time ...
            {
                var _LastLog = await _vehicleLogService.Get(_Vehicle.LastVehicleLogId);

                _LastLog.UpdatedTime = DateTime.Now;
                return(await _vehicleLogService.Update(_LastLog));
            }
        }
Пример #6
0
        public async Task <ActionResult <Result1> > UpdateDeliveryInfo(VehicleLog info)
        {
            try
            {
                DeliverySummary summary = _context.DeliverySummaries
                                          .Where(s => s.Id == info.DeliverySummaryId)
                                          .Include(s => s.Delivery)
                                          .ThenInclude(d => d.Vehicle)
                                          .First();

                Vehicle V = summary.Delivery.Vehicle;
                if (V != null)
                {
                    V.Latitude   = info.Latitude;
                    V.Longtitude = info.Longtitude;
                }

                if (info.HardCornering)
                {
                    summary.HardCorneringRate--;
                    if (summary.HardCorneringRate < 0)
                    {
                        summary.HardCorneringRate = 0;
                    }
                }
                if (info.HarshAccelerationAndDeceleration)
                {
                    summary.HarshAccelerationAndDeceleration--;
                    if (summary.HarshAccelerationAndDeceleration < 0)
                    {
                        summary.HarshAccelerationAndDeceleration = 0;
                    }
                }
                if (info.HarshBreaking)
                {
                    summary.HarshBreakingsRate--;
                    if (summary.HarshBreakingsRate < 0)
                    {
                        summary.HarshBreakingsRate = 0;
                    }
                }
                if (info.OverRevving)
                {
                    summary.OverRevving--;
                    if (summary.OverRevving < 0)
                    {
                        summary.OverRevving = 0;
                    }
                }
                if (info.Speeding)
                {
                    summary.SpeedingsRate--;
                    if (summary.SpeedingsRate < 0)
                    {
                        summary.SpeedingsRate = 0;
                    }
                }
                if (info.SeatBelt)
                {
                    summary.SeatBeltRate--;
                    if (summary.SeatBeltRate < 0)
                    {
                        summary.SeatBeltRate = 0;
                    }
                }
                if (info.EngineRunning && info.Odometer == summary.EndOdometer)
                {
                    summary.Idling--;
                    if (summary.Idling < 0)
                    {
                        summary.Idling = 0;
                    }
                }
                summary.EndOdometer = info.Odometer;

                _context.DeliverySummaries.Update(summary);
                _context.Vehicles.Update(V);
                await _context.SaveChangesAsync();

                return(new Result1(true));
            }
            catch (Exception)
            {
                return(new Result1(false));
            }
        }
Пример #7
0
        public void Insert(VehicleLog vehicleLog)
        {
            _vehicleLogSaver.Insert(vehicleLog);

            throw new System.NotImplementedException();
        }
Пример #8
0
 public void Update(VehicleLog vehicleLog)
 {
     _vehicleLogSaver.Update(vehicleLog);
 }
Пример #9
0
 public ActionResult ModifyVehicleLog(VehicleLog vehicleLog)
 {
     _vehicleLogService.Update(vehicleLog);
     return(Ok());
 }