Example #1
0
 public void UpdateBusRoute(TripRoute route)
 {
     _kzDbContext.Buses.Where(x => x.RoutePlan == route).ToList().ForEach(x => x.RoutePlan = new TripRoute()
     {
         Title    = "Daily",
         Type     = "ordinary",
         Length   = 1,
         TripTime = 1,
         Price    = 1,
         Buses    = null
     });
     _kzDbContext.SaveChanges();
 }
Example #2
0
        public IActionResult CreateRoute(TripViewModel newRoute)
        {
            var route = new TripRoute()
            {
                Title  = newRoute.Title,
                Type   = newRoute.Type,
                Length = newRoute.Length,
                Price  = newRoute.Price
            };

            _tripRouteRepository.Save(route);

            return(RedirectToAction("Index"));
        }
Example #3
0
        public JsonResult RouteHistory(string DriverID)
        {
            var vehicleDriverObj = db.AspNetDriver_Vehicle.FirstOrDefault(s => s.DriverID == DriverID);
            var id = vehicleDriverObj.VehicleID;

            int loopCounter  = 0;
            int routeCounter = 1;
            int counter      = 0;
            List <TripRoute> TripRouteList = new List <TripRoute>();
            var CounterObj = db.AspNetVehicleLocationTables.OrderByDescending(s => s.Id).FirstOrDefault(x => x.VehicleID == id && x.TripStatus == "EndTrip");

            loopCounter = CounterObj.Id;

            do
            {
                var RouteEnd = db.AspNetVehicleLocationTables.OrderByDescending(s => s.Id).FirstOrDefault(x => x.VehicleID == id && x.TripStatus == "EndTrip" && x.Id == loopCounter);
                if (RouteEnd != null)
                {
                    TripRoute route = new TripRoute();
                    route.RouteID    = routeCounter;
                    route.RouteEndID = RouteEnd.Id;
                    AspNetVehicleLocationTable RouteStart = new AspNetVehicleLocationTable();
                    counter = RouteEnd.Id - 1;
                    do
                    {
                        RouteStart = db.AspNetVehicleLocationTables.OrderByDescending(x => x.Id).FirstOrDefault(s => s.Id == counter && s.VehicleID == id && s.TripStatus == "StartTrip");
                        counter--;
                    }while (RouteStart == null && counter > 0);
                    if (RouteStart != null)
                    {
                        route.RouteStartID = RouteStart.Id;
                        TripRouteList.Add(route);
                        loopCounter = RouteStart.Id;
                        routeCounter++;
                        RouteStart = null;
                        RouteEnd   = null;
                    }
                }
                loopCounter--;
            }while (loopCounter > 0);

            return(Json(TripRouteList, JsonRequestBehavior.AllowGet));
        }