Exemplo n.º 1
0
        // GET: Buses/Create
        public ActionResult Create()
        {
            //***************** adding drivers ******************//
            var bus = new Bus();
            bus.Drivers = new List<Driver>();
            PopulateAssignedDriverData(bus);

            bus.Lines = new List<Line>();   //********* adding lines*********************//
            PopulateAssignedLineData(bus); //********* adding lines*********************//
            //************************************************//

            return View();
        }
Exemplo n.º 2
0
        //************************************************//
        //**************** editing lines ***********************//
        private void UpdateBusLines(string[] selectedLines, Bus busToUpdate)
        {
            if (selectedLines == null)
            {
                busToUpdate.Lines = new List<Line>();
                return;
            }

            var selectedLinesHS = new HashSet<string>(selectedLines);
            var busLines = new HashSet<int>
                (busToUpdate.Lines.Select(c => c.LineID));
            foreach (var line in db.Lines)
            {
                if (selectedLinesHS.Contains(line.LineID.ToString()))
                {
                    if (!busLines.Contains(line.LineID))
                    {
                        busToUpdate.Lines.Add(line);
                    }
                }
                else
                {
                    if (busLines.Contains(line.LineID))
                    {
                        busToUpdate.Lines.Remove(line);
                    }
                }
            }
        }
Exemplo n.º 3
0
        //************************************************//
        //**************** editing drivers ***********************//
        private void UpdateBusDrivers(string[] selectedDrivers, Bus busToUpdate)
        {
            if (selectedDrivers == null)
            {
                busToUpdate.Drivers = new List<Driver>();
                return;
            }

            var selectedDriversHS = new HashSet<string>(selectedDrivers);
            var busDrivers = new HashSet<int>
                (busToUpdate.Drivers.Select(c => c.DriverID));
            foreach (var driver in db.Drivers)
            {
                if (selectedDriversHS.Contains(driver.DriverID.ToString()))
                {
                    if (!busDrivers.Contains(driver.DriverID))
                    {
                        busToUpdate.Drivers.Add(driver);
                    }
                }
                else
                {
                    if (busDrivers.Contains(driver.DriverID))
                    {
                        busToUpdate.Drivers.Remove(driver);
                    }
                }
            }
        }
Exemplo n.º 4
0
 //************************************************//
 //********************** adding lines ******************//
 private void PopulateAssignedLineData(Bus bus)
 {
     var allLines = db.Lines;
     var busLines = new HashSet<int>(bus.Lines.Select(c => c.LineID));
     var viewModel = new List<AssignedLineData>();
     foreach (var line in allLines)
     {
         viewModel.Add(new AssignedLineData
         {
             LineID = line.LineID,
             Direction = line.Direction,
             LineNumber = line.LineNumber,
             Assigned = busLines.Contains(line.LineID)
         });
     }
     ViewBag.Lines = viewModel;
 }
Exemplo n.º 5
0
 //********************** adding drivers ******************//
 private void PopulateAssignedDriverData(Bus bus)
 {
     var allDrivers = db.Drivers;
     var busDrivers = new HashSet<int>(bus.Drivers.Select(c => c.DriverID));
     var viewModel = new List<AssignedDriverData>();
     foreach (var driver in allDrivers)
     {
         viewModel.Add(new AssignedDriverData
         {
             DriverID = driver.DriverID,
             DriverName = driver.DriverName,
             DriverSurname = driver.DriverSurname,
             Assigned = busDrivers.Contains(driver.DriverID)
         });
     }
     ViewBag.Drivers = viewModel;
 }
Exemplo n.º 6
0
 public BusForApps(Bus busToBeTransfered)
 {
     this.BusID = busToBeTransfered.BusID;
     this.RegNum = busToBeTransfered.RegNum;
     this.Status = busToBeTransfered.Status;
     this.Latitude = busToBeTransfered.Latitude;
     this.Longitude = busToBeTransfered.Longitude;
     this.Accessible = busToBeTransfered.Status.ToString();
     //obsluzyc driversow i linie
 }