예제 #1
0
        private void AddTransportaionCompany()
        {
            Console.Write("Enter a new ID:");
            int newID = Helper.CheckIntInput();

            TransportationCompany addTransportationCompany = transportationCompanyList.Where(x => x.TransportationCompanyID == newID).FirstOrDefault();

            if (addTransportationCompany != null)
            {
                Console.WriteLine("Sorry,but that ID alredy used!");
            }
            else
            {
                Console.Write("Enter a new name:");
                string newName = Helper.CheckStringInput();

                Console.Write("Enter a new place:");
                string newPlace = Helper.CheckStringInput();

                TransportationCompany addTC = new TransportationCompany {
                    TransportationCompanyID = newID, TransportationCompanyName = newName, TransportationCompanyLocation = newPlace
                };

                transportationCompanyList.Add(addTC);
            }
        }
예제 #2
0
        private void LoadData()
        {
            Autobus autobus1 = new Autobus {
                AutobusType = TipAutobusa.MiniBus, AutobusRegNumber = 382729172
            };
            Autobus autobus2 = new Autobus {
                AutobusType = TipAutobusa.Jednospratni, AutobusRegNumber = 55667788
            };

            TransportationCompany tc1 = new TransportationCompany {
                TransportationCompanyID = 2727, TransportationCompanyName = "Lasta", TransportationCompanyLocation = "Kragujevac"
            };
            TransportationCompany tc2 = new TransportationCompany {
                TransportationCompanyID = 2638, TransportationCompanyName = "Janjusevic", TransportationCompanyLocation = "Subotica"
            };

            Peron peron1 = new Peron {
                PeronID = 242, ArrivalDeparture = new DateTime(2019, 4, 27, 6, 30, 00)
            };
            Peron peron2 = new Peron {
                PeronID = 532, ArrivalDeparture = new DateTime(2019, 3, 30, 9, 30, 00)
            };

            BusStation busStation1 = new BusStation {
                BusStationID = 5832, Location = "Beograd", Peron = peron1
            };
            BusStation busStation2 = new BusStation {
                BusStationID = 9281, Location = "Smederevo", Peron = peron2
            };

            Ticket ticket1 = new Ticket {
                TicketId = 4334, TransportationCompany = tc1, Autobus = autobus1, BusStationArrival = busStation1, BusStationStarting = busStation2
            };
            Ticket ticket2 = new Ticket {
                TicketId = 5555, TransportationCompany = tc2, Autobus = autobus2, BusStationArrival = busStation2, BusStationStarting = busStation1
            };

            autobusList.Add(autobus1);
            autobusList.Add(autobus2);

            transportationCompanyList.Add(tc1);
            transportationCompanyList.Add(tc2);

            peronList.Add(peron1);
            peronList.Add(peron2);

            busStationList.Add(busStation1);
            busStationList.Add(busStation2);

            ticketList.Add(ticket1);
            ticketList.Add(ticket2);
        }
예제 #3
0
        private void RemoveTransportaionCompany()
        {
            Console.Write("Enter the ID of the TC you want to delete:");
            int deleteID = Helper.CheckIntInput();

            TransportationCompany DeleteID = transportationCompanyList.Where(x => x.TransportationCompanyID == deleteID).FirstOrDefault();

            if (DeleteID != null)
            {
                transportationCompanyList.Remove(DeleteID);
            }
            else
            {
                Console.WriteLine("That ID does not exits!");
            }
        }
예제 #4
0
        private void EditTransportaionCompany()
        {
            Console.Write("Please enter TC ID:");
            int selectID = Helper.CheckIntInput();

            TransportationCompany CheckID = transportationCompanyList.Where(x => x.TransportationCompanyID == selectID).FirstOrDefault();

            if (CheckID != null)
            {
                Console.Write("Enter new ID of the transportaion company:");
                int newID = Helper.CheckIntInput();

                Console.Write("Enter new name and lastname of the transportaion company:");
                string newName = Helper.CheckStringInput();

                Console.Write("Enter new place:");
                string newPlace = Helper.CheckStringInput();

                WriteAllAutobuses();

                Console.Write("Enter ID of the autobus:");
                int autobusID = Helper.CheckIntInput();

                Autobus FindAutobus = autobusList.Where(x => x.AutobusRegNumber == autobusID).First();

                List <Autobus> autobusListEdit = new List <Autobus>();
                autobusListEdit.Add(FindAutobus);

                TransportationCompany transportationCompanyEdit = new TransportationCompany {
                    TransportationCompanyID = newID, TransportationCompanyName = newName, TransportationCompanyLocation = newPlace, ListOfBuses = autobusListEdit
                };

                int indexFindedTC = transportationCompanyList.IndexOf(CheckID);
                transportationCompanyList[indexFindedTC] = transportationCompanyEdit;
            }
            else
            {
                Console.WriteLine("This ID does not exits!");
            }
        }
예제 #5
0
        private void AddTicket()
        {
            //Object
            TransportationCompany newTC;
            Autobus    newAutobus;
            BusStation newStart;
            BusStation newArrival;

            Console.Write("Enter a new ticket ID:");
            int newID = Helper.CheckIntInput();

            Ticket CheckID = ticketList.Where(j => j.TicketId == newID).FirstOrDefault();

            if (CheckID != null)
            {
                Console.WriteLine("Sorry,that ID is aleardy exits!");
                return;
            }

            WriteAllTransportaionCompany();
            Console.Write("Enter TC id:");
            int TCid = Helper.CheckIntInput();

            TransportationCompany CheckTCID = transportationCompanyList.Where(x => x.TransportationCompanyID == TCid).FirstOrDefault();

            if (CheckTCID == null)
            {
                Console.WriteLine("Sorry,that ID is aleardy exits!");
                return;
            }

            newTC = CheckTCID;

            WriteAllAutobuses();
            Console.Write("Enter autobus ID:");
            int abID = Helper.CheckIntInput();

            Autobus CheckAubID = autobusList.Where(x => x.AutobusRegNumber == abID).FirstOrDefault();

            if (CheckAubID == null)
            {
                Console.WriteLine("Sorry,that ID is aleardy exits!");
                return;
            }

            newAutobus = CheckAubID;

            WriteAllBusStation();
            Console.Write("Enter bus station id for starting location:");
            int newIDStart = Helper.CheckIntInput();

            BusStation Start = busStationList.Where(x => x.BusStationID == newIDStart).FirstOrDefault();

            if (Start == null)
            {
                Console.WriteLine("Sorry,that ID is aleardy exits!");
                return;
            }

            newStart = Start;

            Console.Write("Enter bus station id for arrival location:");
            int newIDArrival = Helper.CheckIntInput();

            BusStation Arrival = busStationList.Where(x => x.BusStationID == newIDArrival).FirstOrDefault();

            if (Arrival == null)
            {
                Console.WriteLine("Sorry,that ID is aleardy exits!");
                return;
            }

            newArrival = Arrival;

            Ticket newTicket = new Ticket {
                TicketId = newID, Autobus = newAutobus, TransportationCompany = newTC, BusStationStarting = newStart, BusStationArrival = newArrival
            };

            ticketList.Add(newTicket);
        }
예제 #6
0
        private void EditTicket()
        {
            //Objects for edit
            TransportationCompany tcEdit;
            Autobus    abEdit;
            BusStation bsStart;
            BusStation bsArrival;

            Console.Write("Enter ticket ID:");
            int editID = Helper.CheckIntInput();

            Ticket CheckID = ticketList.Where(x => x.TicketId == editID).FirstOrDefault();

            if (CheckID == null)
            {
                Console.WriteLine("That ID does not exits!");
                return;
            }

            Console.Write("Enter a new ticket ID:");
            int newID = Helper.CheckIntInput();

            WriteAllTransportaionCompany();
            Console.Write("Enter TC id:");
            int newTcID = Helper.CheckIntInput();

            TransportationCompany tcCheck = transportationCompanyList.Where(x => x.TransportationCompanyID == newTcID).FirstOrDefault();

            if (tcCheck == null)
            {
                Console.WriteLine("That ID does not exits!");
                return;
            }

            tcEdit = tcCheck;

            WriteAllAutobuses();
            Console.Write("Enter autobus reg number:");
            int regNumEdit = Helper.CheckIntInput();

            Autobus abCheck = autobusList.Where(x => x.AutobusRegNumber == regNumEdit).FirstOrDefault();

            if (abCheck == null)
            {
                Console.WriteLine("That ID does not exits!");
                return;
            }

            abEdit = abCheck;

            WriteAllBusStation();
            Console.Write("Enter id of starting station:");
            int startStation = Helper.CheckIntInput();

            BusStation startBS = busStationList.Where(c => c.BusStationID == startStation).FirstOrDefault();

            if (startBS == null)
            {
                Console.WriteLine("That ID does not exits!");
                return;
            }

            bsStart = startBS;

            Console.Write("Enter id of arrival station:");
            int arrivalStation = Helper.CheckIntInput();

            BusStation arrivalBS = busStationList.Where(b => b.BusStationID == arrivalStation).FirstOrDefault();

            if (arrivalBS == null)
            {
                Console.WriteLine("That ID does not exits!");
                return;
            }

            bsArrival = arrivalBS;

            Ticket editTicket = new Ticket {
                TicketId = newID, TransportationCompany = tcEdit, Autobus = abEdit, BusStationStarting = bsStart, BusStationArrival = bsArrival
            };
            int objectIndex = ticketList.IndexOf(CheckID);

            ticketList[objectIndex] = editTicket;
        }