Пример #1
0
        /// <summary>
        /// a method that creates a new list of the ticket class, adds the ticket to the list and then writes the list to file
        /// </summary>
        public void InitialiseTickets()
        {
            List <Ticket> ticketList = new List <Ticket>();

            ticketList.Add(this);
            Persister.WriteToBinaryFile(@"Tickets.txt", ticketList, false);
        }
Пример #2
0
 public void AddTicketToList(Ticket ticket)
 {
     ticket.InitialiseTicketId();
     _validTicketList = Persister.ReadFromBinaryFile <List <Ticket> >(@_location + "_tickets.txt");
     _validTicketList.Add(ticket);
     Persister.WriteToBinaryFile(@_location + "_tickets.txt", _validTicketList, false);
 }
Пример #3
0
        public void RemoveTimedTicketFromList(Ticket ticket)
        {
            var tickets = Persister.ReadFromBinaryFile <List <Ticket> >(@"Tickets.txt");

            tickets.Remove(ticket);
            Persister.WriteToBinaryFile(@"Tickets.txt", tickets, false);
        }
Пример #4
0
        /// <summary>
        /// A method that calls InitialiseTicketId() and then reads existing tickets into a list of the ticket class and then adds the ticket to the list and writes the list to the file.
        /// </summary>
        public void SerialiseTickets()
        {
            InitialiseTicketId();
            var tickets = Persister.ReadFromBinaryFile <List <Ticket> >(@"Tickets.txt");

            tickets.Add(this);
            Persister.WriteToBinaryFile(@"Tickets.txt", tickets, false);
        }
Пример #5
0
 private void InitialStationLoad() {
     var stations = File.ReadAllLines(@"StationNames.txt");
     List<Station> stationsj = new List<Station>();
     foreach (var singleLine in stations) {
         stationsj.Add(new Station(new DepartureList(), singleLine));
     }
     Persister.WriteToBinaryFile<List<Station>>(@"Stations.txt", stationsj, false);
 }
Пример #6
0
 public void RemoveTicketFromList(Ticket ticket)
 {
     _validTicketList = Persister.ReadFromBinaryFile <List <Ticket> >(@_location + "_tickets.txt");
     foreach (var tick in _validTicketList)
     {
         if (tick.GetTicketId() == ticket.GetTicketId())
         {
             _validTicketList.Remove(tick);
             break;
         }
     }
     Persister.WriteToBinaryFile(@_location + "_tickets.txt", _validTicketList, false);
 }
Пример #7
0
 public void SaveAdminData()
 {
     Persister.WriteToBinaryFile(@"AdminAccounts.txt", _listOfAdminAccounts, false);
 }
Пример #8
0
 /// <summary>
 /// A method that calls the private Persister.WriteToBinaryFile method with the required parameters
 /// </summary>
 public void SaveCustomerData()
 {
     Persister.WriteToBinaryFile(@"Accounts.txt", _listOfAccounts, false);
 }
Пример #9
0
 /// <summary>
 /// A method that writes a ticket to LastTicket.txt which is used to keep ticketids unique
 /// </summary>
 public void InitialiseTicketId()
 {
     Persister.WriteToBinaryFile(@"LastTicket.txt", this, false);
 }
Пример #10
0
 public void InitialiseTicketList(Ticket ticket)
 {
     _validTicketList = new List <Ticket>();
     _validTicketList.Add(ticket);
     Persister.WriteToBinaryFile(@_location + "_tickets.txt", _validTicketList, false);
 }