protected override void Seed(BusTicketSystemContext context) { Country country1 = new Country(); country1.Name = "Bulgaria"; context.Countries.Add(country1); Town town1 = new Town { Country = country1, Name = "Sofia" }; Town town2 = new Town { Country = country1, Name = "Plovdiv" }; Town town3 = new Town { Country = country1, Name = "Varna" }; context.Towns.Add(town1); context.Towns.Add(town2); context.Towns.Add(town3); Customer customer1 = new Customer { FirstName = "Georgi", LastName = "Ivanov", DateOfBirth = new DateTime(1980, 11, 01), Gender = Gender.male, HomeTown = town1 }; Customer customer2 = new Customer { FirstName = "Petar", LastName = "Georgiev", DateOfBirth = new DateTime(1980, 01, 01), Gender = Gender.male, HomeTown = town2 }; context.Customers.Add(customer1); context.Customers.Add(customer2); BankAccount bankAc1 = new BankAccount { AccountHolder = customer1, AccountNumber = "ACN1", Balance = 10000M }; BankAccount bankAc2 = new BankAccount { AccountHolder = customer2, AccountNumber = "ACN2", Balance = 5050.30M }; context.BankAccounts.Add(bankAc1); context.BankAccounts.Add(bankAc2); BusCompany busC1 = new BusCompany { Name = "SpeedExpress", Nationality = "Bulgarian", Rating = 10 }; BusCompany busC2 = new BusCompany { Name = "MegaSpeed", Nationality = "Bulgarian", Rating = 9.9 }; context.BusCompanies.Add(busC1); context.BusCompanies.Add(busC2); BusStation busS1 = new BusStation { Name = "Classic Station", Town = town1 }; BusStation busS2 = new BusStation { Name = "Old Station", Town = town2 }; BusStation busS3 = new BusStation { Name = "Sea Station", Town = town3 }; context.BusStations.Add(busS1); context.BusStations.Add(busS2); context.BusStations.Add(busS3); Review rev1 = new Review { BusCompany = busC1, Customer = customer1, Content = "Blabla review", Grade = 5.5, PublishDate = DateTime.Now }; context.Reviews.Add(rev1); Trip trip1 = new Trip { BusCompany = busC1, DepartureTime = new DateTime(2017, 04, 01), ArrivalTime = new DateTime(2017, 04, 02), DestinationStation = busS2, OriginStation = busS1, Status = Status.departed }; Trip trip2 = new Trip { BusCompany = busC2, DepartureTime = new DateTime(2017, 03, 01), ArrivalTime = new DateTime(2017, 03, 02), DestinationStation = busS1, OriginStation = busS2, Status = Status.departed }; Trip trip3 = new Trip { BusCompany = busC2, DepartureTime = new DateTime(2017, 01, 01), ArrivalTime = new DateTime(2017, 01, 02), DestinationStation = busS1, OriginStation = busS3, Status = Status.delayed }; context.Trips.Add(trip1); context.Trips.Add(trip2); context.Trips.Add(trip3); context.SaveChanges(); base.Seed(context); }
void IDAL.UpdatingStation(BusStation station) { int index = DataSource.BusStations.FindIndex(station1 => station1.StationNumber == station.StationNumber); DataSource.BusStations[index] = index == -1 ? throw new ExceptionStation(station.StationNumber, "bad id - The Station not exist in the compny: {station.StationNumber}") : station.Clone(); }
BusStation IDAL.ReturnStation(int numberStation) { BusStation station = DataSource.BusStations.Find(station1 => station1.StationNumber == numberStation); return(station.Clone() ?? throw new ExceptionStation(numberStation, "bad id - The Station not exist in the compny: {numberStation}")); }
/// <summary> /// StationInfo.xml - All Station Information - Each bus have 1 record in this Collection /// StaticData._busStationCollection /// </summary> private void LoadStationInfo() { UTMConverter utmConverter; StaticData._busStationCollection = new ObservableCollection <BusStationCollection>(); if (!StaticData._busStationCollection.Any()) { StaticData._busStationCollection = new ObservableCollection <BusStationCollection>(); XDocument doc = XDocument.Load("Data/StationInfo.xml"); BusStationCollection newBusStationCollection; foreach (var item in doc.Element("Stations").Elements("Stations")) { newBusStationCollection = new BusStationCollection(); newBusStationCollection.id = item.Attribute("BusNum").Value; foreach (var direction in item.Elements("Direction")) { if (direction.Attribute("go").Value == "1") { newBusStationCollection.goDirection = new ObservableCollection <BusStation>(); foreach (var station in direction.Elements("ID")) { utmConverter = new UTMConverter(); double tempLat = Convert.ToDouble(station.Element("latitude").Value); double tempLon = Convert.ToDouble(station.Element("longitude").Value); //Lat and Lon is in reverse order utmConverter.ToLatLon(tempLon, tempLat, 48, 0); BusStation newBusStation = new BusStation() { id = "[" + station.Attribute("id").Value + "]", number = station.Element("number").Value, address = "đường " + station.Element("address").Value, district = "quận " + station.Element("district").Value, lat = utmConverter.Latitude, lon = utmConverter.Longitude, stationId = station.Element("stationId").Value, }; newBusStationCollection.goDirection.Add(newBusStation); } } if (direction.Attribute("go").Value == "0") { newBusStationCollection.backDirection = new ObservableCollection <BusStation>(); foreach (var station in direction.Elements("ID")) { utmConverter = new UTMConverter(); double tempLat = Convert.ToDouble(station.Element("latitude").Value); double tempLon = Convert.ToDouble(station.Element("longitude").Value); utmConverter.ToLatLon(tempLon, tempLat, 48, 0); BusStation newBusStation = new BusStation() { id = "[" + station.Attribute("id").Value + "]", number = station.Element("number").Value, address = "đường " + station.Element("address").Value, district = "quận " + station.Element("district").Value, lat = utmConverter.Latitude, lon = utmConverter.Longitude, stationId = station.Element("stationId").Value, }; newBusStationCollection.backDirection.Add(newBusStation); } } } StaticData._busStationCollection.Add(newBusStationCollection); } //Enable Async //StorageFile destinationFile = await ApplicationData.Current.LocalFolder.CreateFileAsync( // "placeHolderData.dat", CreationCollisionOption.ReplaceExisting); } }
void IDAL.UpdatingStation(BusStation station) { int index = DataSource.BusStations.FindIndex(station1 => station1.StationNumber == station.StationNumber); DataSource.BusStations[index] = index == -1 ? throw new ExceptionDl("The buses not exist in the compny") : station.Clone(); }
private void AddLineButton_Click(object sender, RoutedEventArgs e) { BusStation Station = (BusStation)DataContext; }
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); }
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; }
public void UpdateStation(int id, Action <BusStation> update) { BusStation sta = DataSource.ListStations.Find(s => s.BusStationKey == id); update(sta); }
public void addStation(BusStation myStation) { ListOfAllStations.Add(new BusStation(myStation)); }