public static Vlucht VluchtUitBestand(string vluchtBestand) { // Bestandsnaam opsporen: FileInfo vluchtBestandInfo = new FileInfo(vluchtBestand); string bestandsNaam = vluchtBestandInfo.Name; // Vluchtobject creëren, bestandsnaam als vluchtcode instellen: Vlucht v = new Vlucht(code: bestandsNaam); // Regels van bestand inlezen in string array: string[] bezettingLijnen = File.ReadAllLines(vluchtBestand); // Elke regel ontleden en in bezettingsobject omzetten: foreach (string bezettingLijn in bezettingLijnen) { // Regel opslitsen: string[] bezettingInfo = bezettingLijn.Split(new char[] { ';' }); // Properties ontleden: string zetel = bezettingInfo[0]; string naam = bezettingInfo[1]; Maaltijd maaltijd = (Maaltijd)Enum.Parse(typeof(Maaltijd), bezettingInfo[2]); // Bezettingsobject creëren: Bezetting b = new Bezetting(zetel, naam) { Maaltijd = maaltijd }; // Bezetting toevoegen aan Bezettingen van Vlucht: v.Bezettingen.Toevoegen(b); } // Vlucht opleveren: return(v); }
private Vlucht _geselecteerdeVlucht; // Eén van de elementen uit bovenstaande lijst. // We houden de verwijzing hiervan bij omdat we van deze vlucht // de gegevens gaan visualiseren, of eventueel uit deze vlucht // bezettingen gaan verwijderen. private void VluchtenComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (VluchtenComboBox.SelectedIndex != -1) // Indien een element geselecteerd: { // Geselecteerde vlucht instellen: _geselecteerdeVlucht = _vluchten[VluchtenComboBox.SelectedIndex]; // Bezettingen weergave-lijst aanpassen: ToonBezettingen(); } }
public ActionResult <Vlucht> GetFlight(int id) { Vlucht flight = _flightRepository.GetbyId(id); if (flight == null) { return(NotFound()); } return(flight); }
private static void TestVlucht() { Vlucht v = new Vlucht(code: "AB01"); Test(v.Code == "AB01", "Constructor stelt code in."); Bezettingen bn = v.Bezettingen; Test(bn != null, "Nieuwe vlucht bevat bezettingen."); Test(bn.Aantal == 0, "Nieuwe vlucht bevat nul bezettingen."); Console.WriteLine(); }
// Statische utility methods voor inladen uit directory/bestanden: public static List <Vlucht> VluchtenUitFolder(string folder) { // Lijst van Vlucht objecten creëren: List <Vlucht> vluchten = new List <Vlucht>(); // Alle bestanden uit directory opvragen: string[] vluchtBestanden = Directory.GetFiles(folder); // Voor elke bestand Vlucht object laten creëren: foreach (string vluchtBestand in vluchtBestanden) { // Vlucht object laten creëren: Vlucht v = VluchtUitBestand(vluchtBestand); // Vlucht aan lijst toevoegen: vluchten.Add(v); } // Lijst opleveren: return(vluchten); }
public async Task InitializeDataAsync() { _dbContext.Database.EnsureDeleted(); if (_dbContext.Database.EnsureCreated()) { Locatie o1 = new Locatie("Brussels", "Avenue 555", 50.900864, 4.484738); Locatie b1 = new Locatie("Iceland", "Brussel", 63.978513, -22.635057); Vlucht f1 = new Vlucht("UC751", o1, b1, 5, new Vliegtuig()); Passagier p1 = new Passagier(1, "Jan", "Janssens"); Passagier p2 = new Passagier(2, "Jef", "Vanvoort"); Passagier p3 = new Passagier(3, "Sara", "Verbeke"); Passagier p4 = new Passagier(4, "Celia", "Vermeulen"); p1.Meldingen.Add(new Melding() { Inhoud = "Welkom aan boord!" }); p2.Meldingen.Add(new Melding() { Inhoud = "Welkom aan boord!" }); p3.Meldingen.Add(new Melding() { Inhoud = "Welkom aan boord!" }); p4.Meldingen.Add(new Melding() { Inhoud = "Welkom aan boord!" }); _dbContext.Passagiers.AddRange(p1, p2, p3, p4); Zetel z1 = new Zetel(1, 'A', "Eerste klasse") { Passagier = p1 }; Zetel z2 = new Zetel(1, 'B', "Eerste klasse") { Passagier = p2 }; Zetel z3 = new Zetel(1, 'C', "Eerste klasse") { Passagier = p3 }; Zetel z4 = new Zetel(2, 'A', "Eerste klasse") { Passagier = p4 }; Zetel z5 = new Zetel(2, 'B', "Eerste klasse"); BestellingOptie optie1 = new BestellingOptie() { Naam = "Fristi", Type = BestellingType.Drinken, Prijs = 4.50 }; BestellingOptie optie2 = new BestellingOptie() { Naam = "Water", Type = BestellingType.Drinken, Prijs = 2 }; BestellingOptie optie3 = new BestellingOptie() { Naam = "Rijstpap", Type = BestellingType.Eten, Prijs = 7.50 }; BestellingOptie optie4 = new BestellingOptie() { Naam = "Steak Natuur", Type = BestellingType.Eten, Prijs = 25 }; _dbContext.BestellingOpties.AddRange(optie1, optie2, optie3, optie4); _dbContext.SaveChanges(); Bestelling bestelling1 = new Bestelling() { Afgehandeld = false, Passagier = p1 }; Bestelling bestelling2 = new Bestelling() { Afgehandeld = false, Passagier = p2 }; Bestelling bestelling3 = new Bestelling() { Afgehandeld = false, Passagier = p1 }; Bestelling bestelling4 = new Bestelling() { Afgehandeld = false, Passagier = p2 }; _dbContext.AddRange(bestelling1, bestelling2, bestelling3, bestelling4); _dbContext.SaveChanges(); BestellingTK tk1 = new BestellingTK { BestellingId = bestelling1.Id, BestellingOptie = optie1 }; BestellingTK tk2 = new BestellingTK { BestellingId = bestelling1.Id, BestellingOptie = optie3 }; BestellingTK tk3 = new BestellingTK { BestellingId = bestelling2.Id, BestellingOptie = optie2 }; BestellingTK tk4 = new BestellingTK { BestellingId = bestelling2.Id, BestellingOptie = optie4 }; BestellingTK tk5 = new BestellingTK { BestellingId = bestelling3.Id, BestellingOptie = optie1 }; BestellingTK tk6 = new BestellingTK { BestellingId = bestelling4.Id, BestellingOptie = optie2 }; _dbContext.BestellingTKs.AddRange(tk1, tk2, tk3, tk4, tk5, tk6); _dbContext.Zetels.AddRange(z1, z2, z3, z4, z5); _dbContext.Locaties.AddRange(o1, b1); _dbContext.Flights.Add(f1); Groepschat groepschat1 = new Groepschat("de coole chat"); groepschat1.Passagiers.Add(p1); groepschat1.Passagiers.Add(p2); ChatBericht cb1 = new ChatBericht(p1, DateTime.Now, "hallo"); ChatBericht cb2 = new ChatBericht(p2, DateTime.Now, "dag"); groepschat1.Chatberichten.Add(cb1); groepschat1.Chatberichten.Add(cb2); _dbContext.Add(groepschat1); await CreateUser("*****@*****.**", "*****@*****.**", "azerty123"); _dbContext.SaveChanges(); } }
public void Update(Vlucht vlucht) { // TODO: Dit mag natuurlijk naar de OnNext methode toe. VertrokkenVanuit = vlucht.VertrokkenVanuit; AantalKoffers = vlucht.AantalKoffers; }
public VluchtViewModel(Vlucht vlucht) { Update(vlucht); // TODO: Vlucht is straks observable, kunnen we daar niet op abonneren? }
public void Remove(Vlucht flight) { _flights.Remove(flight); }
public void Add(Vlucht flight) { _flights.Add(flight); }